Mackeral
Board Regular
- Joined
- Mar 7, 2015
- Messages
- 249
- Office Version
- 365
- Platform
- Windows
Here's the code:
This code finds the largest last row of the indicated columns..
If a column actually has no data in it, then TEMP calculates as 0.
However, the test in the "Do While ...." code doesn't work if "Temp" = 0.
So I need to test for "Temp > 0" to go around it to run that code.
My problem is the test "Temp > 0" is returning TRUE when "Temp" actually has a value of 0.
If I break on the test "Temp > 0" and continue, then the test does work. But that doesn't make sense.
VBA Code:
With SHEET
Last__Row = 0
For Col = Col1 To Col2
Temp = SHEET.Cells(.Rows.Count, Col).End(xlUp).Row + 0
' Test necessary if no data in Column "Col"
If Temp > 0 Then
' Actually Test bottom of Column.
Do While Trim(SHEET.Cells(Temp, Col)) = ""
Temp = Temp - 1
Loop
End If
Last__Row = Maximum(Last__Row, Temp)
Next Col
End With
This code finds the largest last row of the indicated columns..
If a column actually has no data in it, then TEMP calculates as 0.
However, the test in the "Do While ...." code doesn't work if "Temp" = 0.
So I need to test for "Temp > 0" to go around it to run that code.
My problem is the test "Temp > 0" is returning TRUE when "Temp" actually has a value of 0.
If I break on the test "Temp > 0" and continue, then the test does work. But that doesn't make sense.