0

I have this line in a module and it keeps spitting up a run-time error 1004 when I try and run it.

Can anyone help?

I'm guessing it's to do with how the Range is referenced, but i'm not sure. This is all new to me.

rngFirst = ThisWorkbook.Worksheets("Still In Progress").Range("G" & 1 & ":G" & lw)

Many thanks in advance

1
  • 1
    Do you have a sheet called 'Still In Progress'? - and is that 'ell doubleyew' after ":G" &? Commented Aug 13, 2013 at 9:57

2 Answers 2

1

This works for me:

Sub Button1_Click()

Dim rngFirst As Range
Dim int1 As Integer

int1 = 2

Set rngFirst = ThisWorkbook.Worksheets("Sheet1").Range("G" & 1 & ":G" & int1)

rngFirst.Select

End Sub

I was getting the same error as you until I used Dim and Set.

Sign up to request clarification or add additional context in comments.

Comments

1

Your range is not defined correctly. Essentially, you are setting the range to:

"Still In Progress!G1:G1w".

You need to set the last bit of the rngFirst formula to a number (eg at the bottom right hand corner of the range). Something like:

...Range("G" & 1 & ":G" & 20)

if the bottom of your data is at row 20.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.