Code not running and no error showing up

wroze27

New Member
Joined
Apr 23, 2021
Messages
31
Office Version
  1. 2019
Platform
  1. Windows
Can someone please help me figure out why this code doesn't do anything when I run it. I do not get any error message, I click run and then nothing ever happens. I've looked over it enough and I'm blind to what is missing. Any and all help is very appreciated!

The goal of this code is to filter through column G and if the name in the cell matches a name in OS() then it will copy that whole row into a sheet with their name. I removed their names for this example.



VBA Code:
Dim OS(1 To 8) As String
Dim LR As String


OS(1) = "name"
OS(2) = "name"
OS(3) = "name"
OS(4) = "name"
OS(5) = "name"
OS(6) = "name"
OS(7) = "name"
OS(8) = "name"

outside = 1
rowcounter = 2
For outside = 1 To 8
Do Until Sheets("Input").Cells(rowcounter, 1) = "EXIT"
    If Sheets("Input").Cells(rowcounter, "G") = OS(outside) Then
        LR = Sheets(OS(outside)).Cells(Rows.Count, 1).End(xlUp).Row + 1
        For col = 1 To 9
            Sheets(OS(outside)).Cells(LR, col) = Sheets(OS(outside)).Cells(rowcounter, col)
        Next
    Else
    End If
    rowcounter = rowcounter + 1
Loop
Next
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Are the names in the array an exact match (including case) to the names in col G?
 
Upvote 0
Are the names in the array an exact match (including case) to the names in col G?
Yes, exact match. The names in the code, the names in the cell, and the names on the sheets, all perfect matches
 
Upvote 0
Do you have On Error Resume Nextanywhere in your code?
Also do you have any matches for the names before col A has EXIT?
 
Upvote 0
Along with my previous post, this line is copying from the same sheet it's copying to, which seems a bit odd.
VBA Code:
Sheets(OS(outside)).Cells(LR, col) = Sheets(OS(outside)).Cells(rowcounter, col)
 
Upvote 0
Solution
Do you have On Error Resume Nextanywhere in your code?
Also do you have any matches for the names before col A has EXIT?
wow, don't know how i overlooked that. Thank you, fixed and ran it. All works now!
 
Upvote 0
Glad it's sorted & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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