Method 'Range' of object '_Worksheet' failed

WardenBerret

New Member
Joined
Mar 2, 2016
Messages
9
Hi, i am back :P

My vba script is 99% done, but something stupid always happens with me... its like vba is actively working against my progress :(

Now I get the error described in the title and this code is the culprit:
Code:
ws1.Range("A13,C14:C26,A14:A26").Interior.Color = RGB(255, 255, 0)

The thing is, that it worked perfectly before.. i had not changed this specific code any bit except for when I added it... then suddenly it gave me an error. - it happened seemingly after i added the code to export the excel sheet as pdf... but that and the error have nothing in commin so i am stumped :confused:

I've defined the relevant variables as:
Code:
   Dim wbTarget As Workbook 'workbook where the data is to be pasted   Dim ws1      As Worksheet
   
   Set wbTarget = Workbooks.Open("*path*")

   Set ws1 = wbTarget.Sheets("Sheet1")

Big thanks, best regard.
PS. If you need more info, let me know.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I can't edit my own post?

Here's the code, better indented

Code:
Dim wbTarget As Workbook 'workbook where the data is to be pasted
Dim ws1      As Worksheet
Set wbTarget = Workbooks.Open("*path*")
Set ws1 = wbTarget.Sheets("Sheet1")
 
Upvote 0
SOLVED!

If i could edit my post i would add it to the title, but i cant sorry.
I didn't do anything.... it suddenly decided to be my friend -.-
In all seriousness, there was another error in my code with the export as pdf code, when i fixed it my script was running perfectly. I have no idea how the RGB code got fixed, but it is...

Thanks for anyone who helped and/or tried to :)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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