Active code Question

Javi

Active Member
Joined
May 26, 2011
Messages
440
How could I have this code referred to the active sheet not the ("Analyzer - Calculator)?

Code:
Sub Convert_Data_2003()
'
' Convert_Data_2003 Macro
'
    Dim my_range As Range
     
    With Worksheets("Analyzer - Calculator")
         
        Set my_range = .Range("G5:G10000")
        my_range.Formula = _
        "=This_where_My_Formula_Will_Be_input"
 
End With
'
End Sub

Thanks for looking at.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Sub Conver_Data_2003()
Sheets("Analyzer - Calculator").Range("G5:G10000").Formula = "=This_Is_Where_My_Formula_Will_Be_Input"
End Sub
 
Upvote 0
The below is what worked... Thanks for looking at.

Code:
Sub Convert_Data_2003()
'
' Convert_Data_2003 Macro
'
    Dim my_range As Range
     
   [COLOR=red]With Application.ActiveSheet[/COLOR]
<!-- / message -->         
        Set my_range = .Range("G5:G10000")
        my_range.Formula = _
        "=This_where_My_Formula_Will_Be_input"
 
Upvote 0
Sorry, I misread your original post. Corrected version of my code below:
Code:
Sub Convert_Data_2003()
Range("G5:G10000").Formula = "=This_Is_Where_My_Formula_Will_Be_Input"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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