Hi, I'm back again
and hoping you can help me.
Re the above post
I've gone through my sheet and named the ranges that need to be cleared. i.e
Named Range "C_1" refers to =Watch!XEX168,Watch!XFC168,Watch!XFD168,Watch!B168,Watch!C168,Watch!XEX171,Watch!XFA171,Watch!XFB171,Watch!XFC171,Watch!XFD171,Watch!A171,Watch!XEX174,Watch!C173,Watch!B175,Watch!C175,Watch!XFD184,Watch!B184,Watch!XFD187,Watch!B187,Watch!XEX189,Watch!XEX191,Watch!XEY191,Watch!XEZ191,Watch!XFA191,Watch!XFB191
Named Range "C_2" refers to
=Watch!H158,Watch!M158,Watch!N158,Watch!P158,Watch!Q158,Watch!H161,Watch!K161,Watch!L161,Watch!M161,Watch!N161,Watch!O161,Watch!H164,Watch!Q163,Watch!P165,Watch!Q165,Watch!N174,Watch!P174,Watch!N177,Watch!P177,Watch!H179,Watch!H181,Watch!I181,Watch!J181,Watch!K181,Watch!L181
And so on right up to "C_50"
So basically I have 50 sections in my sheet, and within those sections, I need to clear some cell (hence "C1 to C50)
I was going to use a form button within each section, to trigger the clear cells for that section.
i.e there will be 50 buttons, if I click on the button in say section 2 then that would clear "C_2" range, and so on
So I guess what I'm asking is how do I modify your VBA to do this .. I'm not very good at VBA but I'm slowly getting there
The code I was using is:
Sub Clear_W1()
Dim listOfCells As String
Call Clear_These_Cells("ASX_Data", "B9,G9,H9,J9,K9,B12,E12,F12,G12,H12,J12,K14,J16,K16,B15,H25,J25,H28,J28,C30,B32,C32,D32,E32,F32")
End Sub
Sub Clear_These_Cells(sheetName As String, listOfCells As String)
Dim s() As String, rng As Range, i As Long
s = Split(listOfCells, ",")
Set rng = Range(s(0))
For i = 0 To UBound(s)
Set rng = Union(rng, Range(s(i)))
Next i
rng.Value = ""
End Sub