Runtime 1004 error with For Loop

noslenwerd

Board Regular
Joined
Nov 12, 2019
Messages
70
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.
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,766
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
change the line to
VBA Code:
Worksheets("ReviewContent").Cells(RevRow, RevCol)
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,766
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Glad to help...thx for the feedback..🍻
 

Watch MrExcel Video

Forum statistics

Threads
1,123,381
Messages
5,601,302
Members
414,440
Latest member
Kim0204

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
Top