D
davegb
The macro below cleans up spreadsheets created by SPSS. It changes some
cell formatting and replaces a bunch of "#NULLS!" with blanks. But it
hangs up with a "Compile error, variable not defined" error at the line
indicated below. Since Worksheet is an object, not a variable, I don't
understand the message. I even looked it up in the Object Browser. So
why doesn't VBA recognize it? It even capitalized it when I entered it,
which I thought, meant it recognized it. But now it doesn't!
Sub SPSSDownloadCleanup()
Dim FoundCell As Range
Dim CurCol As Range
Set FoundCell = ActiveSheet.Range("a1:z1").find(What:="clientid",
LookIn:=xlFormulas)
If Not FoundCell Is Nothing Then
Set CurCol = Worksheet.Range.Column<----error here
CurCol.NumberFormat = "@"
CurCol.HorizontalAlignment = xlRight
Cells.Replace What:="#NULL!", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Else
End If
Set FoundCell = ActiveSheet.Range("a1:z1").find(What:="stateid",
LookIn:=xlFormulas)
If Not FoundCell Is Nothing Then
Selection.HorizontalAlignment = xlCenter
Else
End If
End Sub
Does anyone see what I'm missing?
Thanks for the help!
cell formatting and replaces a bunch of "#NULLS!" with blanks. But it
hangs up with a "Compile error, variable not defined" error at the line
indicated below. Since Worksheet is an object, not a variable, I don't
understand the message. I even looked it up in the Object Browser. So
why doesn't VBA recognize it? It even capitalized it when I entered it,
which I thought, meant it recognized it. But now it doesn't!
Sub SPSSDownloadCleanup()
Dim FoundCell As Range
Dim CurCol As Range
Set FoundCell = ActiveSheet.Range("a1:z1").find(What:="clientid",
LookIn:=xlFormulas)
If Not FoundCell Is Nothing Then
Set CurCol = Worksheet.Range.Column<----error here
CurCol.NumberFormat = "@"
CurCol.HorizontalAlignment = xlRight
Cells.Replace What:="#NULL!", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Else
End If
Set FoundCell = ActiveSheet.Range("a1:z1").find(What:="stateid",
LookIn:=xlFormulas)
If Not FoundCell Is Nothing Then
Selection.HorizontalAlignment = xlCenter
Else
End If
End Sub
Does anyone see what I'm missing?
Thanks for the help!