I have a report that I have to generate weekly from another application. This other app will kick things out to Excel; what I want to do is automate the formatting process.
Essentially this consists of creating a new worksheet based on the value of cell B (there should only be 4 values) and then within each worksheet, sorting and hiding rows based on a comparison between 2 pairs of cells (e.g. a1:b1, and a2:b2) (W2K, XL2K2)
I did search the FAQ's, and I found a close approximation for what I was doing but I can't make it work since I no longer speak VBA. Can anyone give advice on how to beat this Type Mismatch error?
Essentially this consists of creating a new worksheet based on the value of cell B (there should only be 4 values) and then within each worksheet, sorting and hiding rows based on a comparison between 2 pairs of cells (e.g. a1:b1, and a2:b2) (W2K, XL2K2)
I did search the FAQ's, and I found a close approximation for what I was doing but I can't make it work since I no longer speak VBA. Can anyone give advice on how to beat this Type Mismatch error?
Code:
Sub HideRows()
Dim StartRow As Integer, EndRow As Integer
Dim TargetCol As String, TargetCol1 As String, x As Integer
StartRow = 1
EndRow = 150
TargetCol = "A"
TargetCol1 = "D"
For x = StartRow To EndRow
If Range(TargetCol & x, TargetCol1 & x).Value = Range(TargetCol & x + 1, TargetCol1 & x + 1).Value Then
Range(TargetCol & x + 1).EntireRow.Hidden = True
End If
Next x
End Sub