Let me look through your attachment and see how i can help you. The sheets in the new workbook have to be renamed with the Supplier Code right?
Let me look through your attachment and see how i can help you. The sheets in the new workbook have to be renamed with the Supplier Code right?
Last edited by arlu1201; 10-07-2011 at 06:37 AM.
Yes that's right. Thanks for your help so far. I'm thinking about 3 loops need to run. The first one to cycle through each row. Second to cycle through each column in that row. Third to cycle through all the sheet names in the new workbook created so far to see whether it already exists or not.
One thing to note is that not all columns are populated. Some have more than one supplier code and some don't.
Yes i have done the same thing but facing some probs. Am working on them
I have created this code but its erroring out when i have a sheet with the same name, even though i have an error handler. Maybe someone can help us just modify this a lil bit and it should work for you.
![]()
Sub check_code() Dim SheetName As String Dim ws As Worksheet On Error GoTo Errhandler Fname = ActiveWorkbook.Name Workbooks.Add MName = ActiveWorkbook.Name For i = 1 To Workbooks(Fname).Worksheets("Sheet1").Range("A2").End(xlToRight).Column Step 2 For j = 3 To Workbooks(Fname).Worksheets("Sheet1").Cells(3, i).End(xlDown).Row resume_sheet: Workbooks(Fname).Worksheets(1).Activate SheetName = Workbooks(Fname).Worksheets("Sheet1").Cells(j, i).Text For Each ws In Workbooks(MName).Worksheets If SheetName = "" Or ws.Name = SheetName Then j = j + 1 GoTo stopcode Else Workbooks(Fname).Worksheets("Invoice_Sheet").Copy before:=Workbooks(MName).Sheets(1) If ws.Name = SheetName Then GoTo Errhandler Else Workbooks(MName).Worksheets("Invoice_Sheet").Name = SheetName 'GoTo stopcode End If End If 'Next Next stopcode: Next Next Errhandler: MsgBox Err.Description Application.DisplayAlerts = False ActiveSheet.Delete Application.DisplayAlerts = True GoTo resume_sheet End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks