Forum Discussion
eintracht
Mar 05, 2025Occasional Reader
Using ClearContents on a Range Defined with Variables
I am trying to ClearContents of a range of cells using Variables AND text to define the range.
I have the following code :
Set WithdrawalsRange = WBSC.Range(WBSCCol.Row & "F:" & WBSCCol.Row & "AY")
WithdrawalsRange.ClearContents
WBSCCol.Rows = 4 that I use to perform other tasks with no problem.
So I want to ClearContents of the range "4F:4AY" in the WBSC worksheet. I am struggling to come up with the right syntax.
So my Set statement I want to be translated as :-
Set WithdrawalsRange = WBSC.Range("4F:4AY") but I keep getting a
Run-time error '1004'.
Applicsation-defined or object-defined error.
Would be grateful if someone could show me the error of my ways.
WBSC is a Worksheet
WithdrawalsRange is a Range
Many thanks
Chris
The range should be F4:AY4 instead of 4F:4AY, so use
Set WithdrawalsRange = WBSC.Range("F" & WBSCCol.Row & ":AY" & WBSCCol.Row)