if goto inside for loop

gal12

New Member
Joined
Feb 3, 2021
Messages
10
Office Version
  1. 2019
Platform
  1. Windows
hello,

i'm trying to do an if go to fuction inside a for loop and i get an error.
please help me understand what i did wrong.

VBA Code:
Sub CopyToMaster()
Dim destination As Worksheet
Dim emptyColumn As Long
Dim j As Long
Dim cell As Range
Set destination = Sheets("MASTER")
ShtCount = ActiveWorkbook.Sheets.Count
 
For i = 3 To ShtCount
        Worksheets(i).Activate
 
        If Range("C2,A7:J31").SpecialCells(xlCellTypeConstants).Select Is Nothing Then
            GoTo line2
            Else: GoTo line1
        End If
line1:
        Range("C2,A7:J31").SpecialCells(xlCellTypeConstants).Select
        emptyColumn = destination.Cells(1, i - 2).Column
            j = 0
            For Each cell In Selection
                destination.Cells(emptyColumn).Offset(j).Value = cell.Value
                j = j + 1
            Next cell
line2:
Next i
Worksheets("MASTER").Activate
End Sub
 
You're welcome & thanks for the feedback.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,214,840
Messages
6,121,895
Members
449,058
Latest member
Guy Boot

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