• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Need VBA to clear contents of range of cells

Below is the beginning part of my code. As you see there are two sheets where I clear contents from a range of cells on "Ratesheet" and Ratesheet2". I also want to clear contents on these cells 'VA_IRRRL!R7:S33' every time the marco is run. Please advise what code should be inserted to clear these cells as well.

Code:
Sub GetRS_FHA1_1()

On Error GoTo ErrHand:

Dim ws As Worksheet, ws2 As Worksheet
Dim JsonText As String
Dim Parsed As Dictionary

Set ws = Sheets("Ratesheet")
Set ws2 = Sheets("Ratesheet2")

'clear old
ws.Range(ws.Cells(41, 1), ws.Cells(72, 2)).ClearContents
ws.Range(ws.Cells(41, 5), ws.Cells(72, 6)).ClearContents

'clear Ratesheet2
ws2.Range(ws2.Cells(41, 1), ws2.Cells(72, 2)).ClearContents
ws2.Range(ws2.Cells(41, 5), ws2.Cells(72, 6)).ClearContents

'send URL
Dim hReq As Object, JSON As Dictionary
 
Last edited by a moderator:
Sheets("VA_IRRRL").Range("R7:S33").ClearContents
I inserted and ran the code but the contents did not clear. Am I missing something?

Code:
Sub GetRS_FHA1_1()

On Error GoTo ErrHand:

Dim ws As Worksheet, ws2 As Worksheet
Dim JsonText As String
Dim Parsed As Dictionary

Set ws = Sheets("Ratesheet")
Set ws2 = Sheets("Ratesheet2")

'clear old
ws.Range(ws.Cells(41, 1), ws.Cells(72, 2)).ClearContents
ws.Range(ws.Cells(41, 5), ws.Cells(72, 6)).ClearContents
'clear Ratesheet2
ws2.Range(ws2.Cells(41, 1), ws2.Cells(72, 2)).ClearContents
ws2.Range(ws2.Cells(41, 5), ws2.Cells(72, 6)).ClearContents
'clear VA_IRRRL
Sheets("VA_IRRRL").Range("R7:S33").ClearContents

'send URL
Dim hReq As Object, JSON As Dictionary
 
Last edited by a moderator:
Back
Top