View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Loomis Ken Loomis is offline
external usenet poster
 
Posts: 143
Default <Method 'Range' of object '_Global' failed error

When I run this macro,

Sub addLeadType(leadType As Integer)
Dim totalrows As Integer
Dim typeCol As Integer

typeCol = 11

' The following line generates the error
Range(Cells(1, typeCol)).Value = "Lead Type"


totalrows = ActiveSheet.UsedRange.Rows.count
Range(Cells(2, typeCol), Cells(totalrows, typeCol)).Value = leadType
End Sub

I get a "<Method 'Range' of object '_Global' failed error at the line
indicated above.

I tried hard coding the "11" in place of typeCol and get the same error.

Can someone tell me what I am doing wrong here?

Thanks,
Ken Loomis