Runtime 1004 error with For Loop

noslenwerd

Board Regular
Joined
Nov 12, 2019
Messages
85
Office Version
  1. 365
The code below is throwing me a runtime 1004 error when I try to run the macro: Denoted with "'THIS IS WHERE THE ERROR OCCURS"

I suspect this is because I am using checkboxes in the "Deliverables" worksheet to start the For, and writing content to the "ReviewContent" worksheet after the If statement.

Any ideas?

VBA Code:
Sub acheckboxtext()
Dim Data()  As Byte
Dim RevCol, RevRow As Long
Dim File    As String
Dim Text    As String
Dim cel As Range

RevCol = 27
RevRow = 3
    For Each cel In Worksheets("Deliverables").Range("C10:C17")
        If cel.Value = True Then
            File = "C:\testing\worksheet\data\conversion\socialproof.txt"
            Open File For Binary Access Read As #1
                ReDim Data(LOF(1))
                Get #1, , Data
            Close #1
            ' // Convert bytes into a Unicode string.
            Text = StrConv(Data, vbUnicode)
           Worksheets("ReviewContent").Range(RevCol, RevRow) = Text 'THIS IS WHERE THE ERROR OCCURS
        End If
             RevCol = RevCol + 1
    Next cel
End Sub

When I replace the above with the code below, it runs fine (but will not work as I need to insert 'Text' into a series of columns

VBA Code:
            Worksheets("ReviewContent").Range("AA" & 3) = Text

The questions is only posted here. Thank you for your help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
change the line to
VBA Code:
Worksheets("ReviewContent").Cells(RevRow, RevCol)
 
Upvote 0
Glad to help...thx for the feedback..?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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