VBA Run-time error '1004'

epactheactor

New Member
Joined
Sep 9, 2015
Messages
38
Hello everyone.

I'm trying to finish the most complex macro I've ever done and have run into an error that is blowing my mind. I'm learning VBA so I would like to understand the error and not just get a fix, if that makes sense, so I don't make it again.

I get an the '1004' error on my Boo variable and I don't know why.

Code:
Sub RunScores

Dim Boo As String
Set XYZWorkbook = ActiveWorkbook
Boo = "A8"
'Goes through each subsegment
'If it is blank, it stops


Do While IsEmpty(Range(Boo).Value) = False
    Range(Boo).UnMerge
    Call FillInScores
    Range(Boo).Select
    Boo = Range(Boo).Offset(3, 0)
Loop

End Sub

Previously I wasn't using a loop and was renaming the Boo variable manually as well as well as repeating the code and it ran fine. But for what i am using it for, there could be 2 subsegments, or 100 so I really need to use a loop.

Thank you for any help.
 
Last edited by a moderator:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try making this change
Code:
Boo = Range(Boo).Offset(3, 0)[COLOR=#ff0000].Address[/COLOR]
 
Upvote 0
This line will just give you the value of what is in A11:

Code:
boo = Range(boo).Offset(3, 0)

so maybe use .Address

Code:
boo = Range(boo).Offset(3, 0).Address
 
Upvote 0
For this, the error it gives is on the first "Do While IsEmpty(Range(Boo).Value) = False" As it shows there is no value in the Boo variable. Why would this be if I have declared it and given it a string input? The Offset line would be once it has completed the first run and checks for the next.
 
Upvote 0
I suspect that A11 is a blank cell
 
Upvote 0
Yes and no. It's a weird workbook, the sort you really wish you could change to make more logical. Cells (A8:A10) are merged together. So I found that instead of (3,0) offset I really need to use (1,0) offset as (A11:A13) would have a value.

Overall I think I understand the error I was making. I wasn't fully telling it what cell to go to next to rename that variable.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top