Grabbing a cell variable more efficiently

Zarcero

New Member
Joined
Jun 19, 2008
Messages
19
I have some VBA code that is grabbing a value I have in a worksheet cell. Currently it looks like this:

:
Worksheets("Tank_GAP_Macro").Select
OptToggle = Range("f45")
If OptToggle = 1 Then
DoGAPFunc ("GAP.PREDDOSTEP(1)")
ElseIf OptToggle = 0 Then
DoGAPFunc ("GAP.PREDDOSTEP(0)")
End If
:

I want to get the value that resides in "f45" but I want to do this without having to select the worksheet. Is there a more efficient way to get the value in "f45" without have to use the .select command.

Thanks,
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi, Zarcero.
You can use this code in any modules
Code:
OptToggle = Workshets("Tank_GAP_Macro").Range("F45").Value

However, if you wanted a simpler looking code (not neccessarily faster), put this in your Tank_GAP_Macro worksheet module
Code:
OptToggle = Range("F45").Value
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

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