Is there a way to clear a cell value without selecting the cell?

stuckagain22

Board Regular
Joined
Aug 4, 2006
Messages
183
I have a macro that runs on my sheet that clears the value of a cell in a hidden row. When I click on the object that launches the macro the whole screen moves down to where the hidden value is. It takes about .5 seconds to run the macro. I just don't like how the screen jumps down and then up again. I was wondering if there is any way to clear a cell value without "physically" jumping to the cell?

Here is my current code:
Code:
Sub LEVELS_RESETQUERY()
    Sheets("Levels").Select
    Range("D184").Select
    ActiveCell.FormulaR1C1 = "1"
    Sheets("Levels").Select
    Range("D3:D5").Select
End Sub

I would appreciate it if someone could advise if this is possible or not.

Thank you.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Maybe just

Code:
Sub LEVELS_RESETQUERY()
    Worksheets("Levels").Range("D184").Value = 1
End Sub

You rarely need to select anything in VBA, and it's faster not to.
 
Upvote 0
something like: ?
Code:
Sub LEVELS_RESETQUERY()
    Sheets("Levels").Range("D184").FormulaR1C1 = "1"
    Sheets("Levels").Range("D3:D5").Select
End Sub
 
Upvote 0
There is no need to select
Code:
Sub Levels_ResetQuery()
    With Sheets("Levels")
        .Range("D184").Value = 1
        .Range("D3:D5").ClearContents
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,189
Members
452,893
Latest member
denay

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