Select method of Range class failed error message

A

Ayo

I have this section of code but I get the above error message whenever I get
to the last line:
rngInsitehdr.Select
I can't figure it out. Any ideas?
Thanks.

Set insiteWS = Worksheets("InSite Data")
Set rngInsitehdr = insiteWS.Range("A2:" & insitelastColumn & insitelastRow)
rngInsitehdr.Select
 
A

Ayo

insitelastColumn is a string. This is the whole section:

Set insiteWS = Worksheets("InSite Data")
Set progressWS = Worksheets("Progress")
insitelastRow = insiteWS.Range("A65536").End(xlUp).Row
progresslastRow = progressWS.Range("A65536").End(xlUp).Row

insPos = InStr(1,
insiteWS.Range("IV1").End(xlToLeft).Address(ColumnAbsolute:=False), "$",
vbTextCompare)
insitelastColumn =
Left(insiteWS.Range("IV1").End(xlToLeft).Address(ColumnAbsolute:=False),
insPos - 1)
proPos = InStr(1,
progressWS.Range("IV4").End(xlToLeft).Address(ColumnAbsolute:=False), "$",
vbTextCompare)
progresslastColumn =
Left(progressWS.Range("IV4").End(xlToLeft).Address(ColumnAbsolute:=False),
proPos - 1)

Set rngProgresshdr = progressWS.Range("A4:" & progresslastColumn & "4")
Set rngInsitehdr = insiteWS.Range("A2:" & insitelastColumn & insitelastRow)

rngInsitehdr.Select
Selection.Copy
progressWS.Select
ActiveSheet.Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

it worked fine a couple of times at first, but when I reopened the file and
tried to run it again the error occured and now I am stucked at
rngInsitehdr.Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top