Home Excel VBA using Range with variables
Reply: 2

Excel VBA using Range with variables

Josh
1#
Josh Published in 2018-01-12 17:05:07Z

I am trying to clear a range of cells with the use of a variable. For some background I have values in A-G that will be updated regularly while the values in I-K need to remain constant.

I am trying to use the value stored in myCell (in this example A8) to guide my clear command to be everything from it to G100

Range(myCell, "G100").ClearContents

I have tried several variations of this but it never seems to take so there must be something I am missing.

Thanks for looking!

SJR
2#
SJR Reply to 2018-01-12 17:06:21Z

You're close.

Range(myCell, range("G100")).ClearContents
Daniel Elmnas
3#
Daniel Elmnas Reply to 2018-01-12 17:23:54Z

You could:

Sub ClearCell()
Range("G100").Clear
End Sub

or

Sub VBA_Clear_Contents_Range()
Range("G100").ClearContents
End Sub

or

Sub DeleteG100()   
    Range("G100").Select
    Selection.ClearContents
end sub

Regards

Daniel

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.294005 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO