Hi,
I have an Order tracking spreadsheet that I need help with.
I have a 2 worksheets "Open", and "Closed".
I have entries on the "Open" sheet which may or may not be grouped together. I've called the rows :Parents and Children. There are basically 3 types of rows. Parents with Children, Parents without Children, and Children. I have a reference cell for each row, where I identify what type of row it is, "-1" = Child, "0" = Parent with no Children, and (a number > 1) is a parent with that many children. If an entry contains just 1 detail item, the detail data is stored in the Parent row (with no children), if an entry has 2+ detail items, each of the sub items is stored on a Child Row, and is Grouped below the parent row.
The User of this spreadsheet will put an "X" into a cell to specify that it is closed. For Parents with no children, and Children rows, I just run a Worksheet Change event that copies them over Like this:
Code:
From reading other posts on this website and other websites, I've read that the Worksheet_Calcu ate Event calls the Worksheet_Chang e event at the end of it. So, would there be a way to take the "target" Row from the Calculate event and pass it to the Worksheet_Chang e event?
With Parents with Children, the user will put an X into each Child row as that item is delivered. The Children items may not arrive at the same time. The Meaningful cells (for this problem) for the parents and Children are as follows:
Parent: B4[=Sum(B5:B7)] C4[=if(B4=3, "X", "") CA4[3](column 79)
Child: B5[=IF(UPPER(C5)=" X",1,0)] C5[blank] CA5[-1]
Child: B6[=IF(UPPER(C6)=" X",1,0)] C6[blank] CA6[-1]
Child: B7[=IF(UPPER(C7)=" X",1,0)] C7[blank] CA7[-1]
Parent (no kids): B8[blank] C8[blank] CA8[0](column 79)
If the user puts an "X" in a child row, the code above ignores that. If the user puts an "X" in a parent with no children row, the row is cut and pasted into the "closed" sheet.
I need help figuring out what I need to add to the Worksheet_Calcu late Event, to pass the target to the Worksheet_Chang e event. One idea I had while I was typing this, was maybe I check if Target.Cells(Ta rget.Row, 79) > 0, and set up a for loop that will loop through each parent and children, and copy them over to the closed sheet.
Any suggestions/ideas or comments are appreciated.
Thanks,
Sitko.
I have an Order tracking spreadsheet that I need help with.
I have a 2 worksheets "Open", and "Closed".
I have entries on the "Open" sheet which may or may not be grouped together. I've called the rows :Parents and Children. There are basically 3 types of rows. Parents with Children, Parents without Children, and Children. I have a reference cell for each row, where I identify what type of row it is, "-1" = Child, "0" = Parent with no Children, and (a number > 1) is a parent with that many children. If an entry contains just 1 detail item, the detail data is stored in the Parent row (with no children), if an entry has 2+ detail items, each of the sub items is stored on a Child Row, and is Grouped below the parent row.
The User of this spreadsheet will put an "X" into a cell to specify that it is closed. For Parents with no children, and Children rows, I just run a Worksheet Change event that copies them over Like this:
Code:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wb As Excel.Workbook
Dim oDataWS_O As Worksheet
Dim oDataWS_C As Worksheet
Dim startRow as Integer
Dim bfound as boolean
dim entryRow as Integer
Set wb = ActiveWorkbook
Set oDataWS_O = wb.Worksheets("Open")
Set oDataWS_C = wb.Worksheets("Closed")
'This is the start of the Moving rows to closed sheets sub
'Do nothing if more than one cell is changed or content deleted
If Target.Cells.Count > 1 Or IsEmpty(Target) Or Target.Cells.Value <> "X" Then Exit Sub
If Not Intersect(Target, Range("C1:C65000")) Is Nothing Then
If Target.Cells(Target.Row, 79) = -1 Then 'a child
Exit Sub
End If
If Target.Cells(Target.Row, 79) = 0 Then 'a child-less parent
startRow = 3
bfound = False
Do Until oDataWS_O.Cells(startRow, 5) = ""
If oDataWS_O.Cells(startRow, 5) = "Reference" Then
entryRow = startRow
bfound = True
Exit Do
End If
startRow = startRow + 1
'Next
Loop
'Appending a row to the tracking spreadsheet
'Rows(CStr(entryRow) + ":" + CStr(entryRow)).Select
'make room for the parent on the closed sheet
oDataWS_C.Rows(entryRow).Copy
oDataWS_C.Rows(entryRow).Insert Shift:=xlDown
'Move the parent to the closed sheet
oDataWS_O.Rows(Target.Row).Cut
oDataWS_C.Rows(entryRow).Paste
Else
Exit Sub
End If
End Sub
With Parents with Children, the user will put an X into each Child row as that item is delivered. The Children items may not arrive at the same time. The Meaningful cells (for this problem) for the parents and Children are as follows:
Parent: B4[=Sum(B5:B7)] C4[=if(B4=3, "X", "") CA4[3](column 79)
Child: B5[=IF(UPPER(C5)=" X",1,0)] C5[blank] CA5[-1]
Child: B6[=IF(UPPER(C6)=" X",1,0)] C6[blank] CA6[-1]
Child: B7[=IF(UPPER(C7)=" X",1,0)] C7[blank] CA7[-1]
Parent (no kids): B8[blank] C8[blank] CA8[0](column 79)
If the user puts an "X" in a child row, the code above ignores that. If the user puts an "X" in a parent with no children row, the row is cut and pasted into the "closed" sheet.
I need help figuring out what I need to add to the Worksheet_Calcu late Event, to pass the target to the Worksheet_Chang e event. One idea I had while I was typing this, was maybe I check if Target.Cells(Ta rget.Row, 79) > 0, and set up a for loop that will loop through each parent and children, and copy them over to the closed sheet.
Any suggestions/ideas or comments are appreciated.
Thanks,
Sitko.
Comment