Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a worksheet that has a header column. Underneath it has two info
columns. There is a column between Hours and the date, there is another column between names. I copy this sheet from another sheet which has everyone's name then delete certain names based on office. I also delete the hours columns on the names I keep as I do not need them and would have to re-write many other modules which were based on the sheet not having that column. Someones Name Total Hours Nov 1 - 15, 07 Hours Nov 1-15,07 86.67 2,500.00 86.67 2,500.00 I look at the name, if it is on the list I delete the Hours and (hours +1) columns moving everything to the left, then I delete the two blank cells by the name to line everything up again. The total figure adjusts correctly. If the name is not on the list I delete the name column and the next 3 columns. When I do this the Total column does not update correctly and I get a #ref in the cell. Here is the code: With Sheets("Shreveport") lastCol = .Cells(1, "IV").End(xlToLeft).Column For i = lastCol To 1 Step -1 If Len(Trim(.Cells(1, i))) < 0 Then If Application.CountIf(Workbooks("Employee List for Payroll1") _ .Worksheets("List").Columns(2), .Cells(1, i)) = 0 Then .Columns(i).Delete .Columns(i + 1).Delete .Columns(i + 1).Delete .Columns(i).Delete ElseIf Application.CountIf(Workbooks("Employee List for Payroll1") _ .Worksheets("List").Columns(2), .Cells(1, i)) 0 Then Range(Cells(2, i), Cells(65536, i + 1)).Select Selection.Delete xlShiftToLeft Range(Cells(1, i + 1), Cells(1, i + 2)).Select Selection.Delete xlShiftToLeft End If End If Next End With What can I do so the Total column continues to adjust itself? As that column is what I base several other worksheets on. Thanks, Kevin Porter |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can you post sample of data that is on Shreveport and List worksheets along
with the column the data is located along with any formulas that are in the cell. I can't tell from the posting where the #ref is occuring. "Kevin Porter" wrote: I have a worksheet that has a header column. Underneath it has two info columns. There is a column between Hours and the date, there is another column between names. I copy this sheet from another sheet which has everyone's name then delete certain names based on office. I also delete the hours columns on the names I keep as I do not need them and would have to re-write many other modules which were based on the sheet not having that column. Someones Name Total Hours Nov 1 - 15, 07 Hours Nov 1-15,07 86.67 2,500.00 86.67 2,500.00 I look at the name, if it is on the list I delete the Hours and (hours +1) columns moving everything to the left, then I delete the two blank cells by the name to line everything up again. The total figure adjusts correctly. If the name is not on the list I delete the name column and the next 3 columns. When I do this the Total column does not update correctly and I get a #ref in the cell. Here is the code: With Sheets("Shreveport") lastCol = .Cells(1, "IV").End(xlToLeft).Column For i = lastCol To 1 Step -1 If Len(Trim(.Cells(1, i))) < 0 Then If Application.CountIf(Workbooks("Employee List for Payroll1") _ .Worksheets("List").Columns(2), .Cells(1, i)) = 0 Then .Columns(i).Delete .Columns(i + 1).Delete .Columns(i + 1).Delete .Columns(i).Delete ElseIf Application.CountIf(Workbooks("Employee List for Payroll1") _ .Worksheets("List").Columns(2), .Cells(1, i)) 0 Then Range(Cells(2, i), Cells(65536, i + 1)).Select Selection.Delete xlShiftToLeft Range(Cells(1, i + 1), Cells(1, i + 2)).Select Selection.Delete xlShiftToLeft End If End If Next End With What can I do so the Total column continues to adjust itself? As that column is what I base several other worksheets on. Thanks, Kevin Porter |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need help updating 1 cell from other cells in same column | Excel Discussion (Misc queries) | |||
Total cells of one column based on the values in another column? | New Users to Excel | |||
Count number of cells and total in one column, based on another column suffix | Excel Worksheet Functions | |||
Because of row/column deletions, how do you reset the last cell? | Excel Discussion (Misc queries) | |||
calculate which cells in column A will give me the total of column | Excel Worksheet Functions |