Small Paul

Board Regular
Joined
Jun 28, 2018
Messages
118
Hi
I have the following section of code within a large macro:

Code:
Worksheets("Dubai Data").ActivateActiveCell.Offset(0, 2).Copy
detail = ActiveCell.value


[I]Sheets(detail).Select

[/I]
ActiveCell.Offset(-2, 1).PasteSpecial xlPasteValues
ActiveCell.Font.Bold = True
Range(cells(ActiveCell.row, "C"), cells(ActiveCell.row, "K")).MergeCells = True
Range("C8:K8").HorizontalAlignment = xlCenterAcrossSelection
Worksheets("Dubai Data").Activate
ActiveCell.Offset(0, 13).Select
If Selection.value <> "None" Then
Selection.Copy
ActiveCell.Select
detail = ActiveCell.value

[I]Sheets(detail).Select[/I]

Range("B4").PasteSpecial xlValues

"Sheets Detail" takes you to a specific worksheet. The first instance works above (not the first in the macro) works correctly. For some bizarre reason I am getting a
"Run Time Error 9: Subscript Out Of Range" error on the second case above.
Both instances are pointing to the same worksheet!

Any suggestions as to what I am doing wrong?

Cheers
Small Paul.
 
Last edited:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Re: Run Time Error 9 - Makes Absolutely No Sense!!!

I would wonder which cell is active when the error occurred and what it contains. i.e. what the value of detail is when it errors.
 
Upvote 0
Re: Run Time Error 9 - Makes Absolutely No Sense!!!

Hi Mikerickson
The value is '1' and takes the user to worksheet '1'.
But you have hit the nail on the head - I have now set the cell in column A to activate!
Man, many thanks
Small Paul.
 
Upvote 0

Forum statistics

Threads
1,214,795
Messages
6,121,624
Members
449,041
Latest member
Postman24

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