willyboy58
Technical User
I am trying to get the following procedure to read a row of information, find the cells in the row that are NOT empty (they will have a number in them) and then shift one column to the right and insert an “L” or an “H” (two separate procedures at this point) in the empty column to the right.
The brief worksheet looks like the following. A2 is the first activecell.
A B C D E F
1 name job 05-01-03 5-02-03
2 Bob 186 6.0
3 Steve 188 6.0
4 Mike 189 6.0
5 Frank 188 6.0
Row 1 is my headings: 2 on down is the employee name, job # and hours. Columns D and F are the empty columns to place an L or H into.
In the procedure below, if the value in the activecell in column B (above) is equal to 186 or 189 then I want an “L” in the empty column next to the hours in the row for that day (Bob and Mike, column D). If it is 188, then I want an “H” (Steve and Frank, column F). When it finishes with one row, it starts the next. I have the code (a different procedure) to count the number of entries across for each row, but I’m not sure how to tell it to go to the next row of info. The following is for the "L" only. I'll write a separate one for the "H".
Sub ActivateNextCellToRightL()
Dim LeaveHours As String
LeaveHours = "L"
ActiveCell.Offset(0, 1).Select
Do While IsEmpty(ActiveCell)
With ActiveCell
ActiveCell.Offset(0, 1).Select
LeaveHours = ActiveCell.Offset(0, 1).Select
End With
Loop
End Sub
The procedure above stops at each cell of info in the row, but it will not move to the next column (empty cell) to put the “L” into and then move across to the next cell. There will be about 30 columns of info. The above is only a small part of a much larger program.
Any help will be greatly appreciated. TIA. Bill
The brief worksheet looks like the following. A2 is the first activecell.
A B C D E F
1 name job 05-01-03 5-02-03
2 Bob 186 6.0
3 Steve 188 6.0
4 Mike 189 6.0
5 Frank 188 6.0
Row 1 is my headings: 2 on down is the employee name, job # and hours. Columns D and F are the empty columns to place an L or H into.
In the procedure below, if the value in the activecell in column B (above) is equal to 186 or 189 then I want an “L” in the empty column next to the hours in the row for that day (Bob and Mike, column D). If it is 188, then I want an “H” (Steve and Frank, column F). When it finishes with one row, it starts the next. I have the code (a different procedure) to count the number of entries across for each row, but I’m not sure how to tell it to go to the next row of info. The following is for the "L" only. I'll write a separate one for the "H".
Sub ActivateNextCellToRightL()
Dim LeaveHours As String
LeaveHours = "L"
ActiveCell.Offset(0, 1).Select
Do While IsEmpty(ActiveCell)
With ActiveCell
ActiveCell.Offset(0, 1).Select
LeaveHours = ActiveCell.Offset(0, 1).Select
End With
Loop
End Sub
The procedure above stops at each cell of info in the row, but it will not move to the next column (empty cell) to put the “L” into and then move across to the next cell. There will be about 30 columns of info. The above is only a small part of a much larger program.
Any help will be greatly appreciated. TIA. Bill