I have to write a code that will make copy of two sheets into new workbook. However, I receve error message and the values do not show..
Public Sub CopySheetAndRename()
Dim newName As String
On Error Resume Next
newName = InputBox("Enter the name for the copied worksheet")
If newName <> "" Then
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = newName
End If
End Sub
Sub SaveSheets()
Application.DisplayAlerts = False
Dim myFile
Dim myCount
Dim actSheet
Dim i
Dim WsTabelle As Worksheet
'mypath = InputBox("Enter the path", "Save to...", "C:\temp")
mypath = "C:\temp"
ChDrive mypath
ChDir mypath
Sheets("Fertigstellungsgrad aktuell").Select
Sheets("Fertigstellungsgrad aktuell").Copy Before:=Sheets("Fertigstellungsgrad aktuell")
Sheets("Fertigstellungsgrad aktuell").Select
Sheets("Fertigstellungsgrad aktuell (2)").Name = "Fertigstellungsgrad xx.xx.xx"
ActiveWorkbook.SaveAs Filename:= _
"C:\temp\Bearbeitungsstatus.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
' Löschen überflüssiger Sheets
For Each WsTabelle In Sheets
With WsTabelle
' Dein Makro, Cells und Range mit Punkt
actSheet = .Name
If .Name = "Fertigstellungsgrad xx.xx.xx" Then
' mache nichts
actSheet = .Name
ElseIf .Name = "Übersicht AP-Verbrauch" Then
' mache nichts
actSheet = .Name
Else
WsTabelle.Delete
End If
End With
Next WsTabelle
ActiveWorkbook.SaveAs Filename:= _
" C:\temp \Bearbeitungsstatus.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
Public Sub SubstitudeFieldValues()
Sheets("Fertigstellungsgrad xx.xx.xx").Select
' Find the last row of data
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
FinalCol = Cells(1, Columns.Count).End(xlToLeft).Column
' Loop through each row
For Col = 1 To FinalCol
colTitle = Cells(1, Col).Value
If colTitle = "K1" Or _
colTitle = "K2" Or _
colTitle = "K3" Or _
colTitle = "S1" Or _
colTitle = "S2" Or _
colTitle = "S3" Or _
colTitle = "P1" Or _
colTitle = "P2" Or _
colTitle = "P3" Or _
colTitle = "T1" Or _
colTitle = "T2" Or _
colTitle = "T3" Or _
colTitle = "A1" Or _
colTitle = "A2" Or _
colTitle = "D1" Or _
colTitle = "D2" Then
For x = 2 To FinalRow
wert = Cells(x, Col)
If wert <> Leer Then
'Range(Cells(x, Col), Cells(x, Col)).Select
Cells(x, Col).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next x
End If
Next Col
End Sub
The original task is to make copy of two sheets in the new workbook.
Making a copy of "Fertigstellungsgrad" with ability of rename (It should be called "Fertigstellungsgrad xx.xx.xx" - Date.Month.Year) and the copy should contain only values. "Übersicht AP-Verbrauch"(this one should stay the same, without any changes)
https://i.stack.imgur.com/Soxq7.png
Kind regards, Mario
There are spaces in the filenames in Sub SaveSheets()
I changed:
ActiveWorkbook.SaveAs Filename:= _
" C:\temp \Bearbeitungsstatus.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
to
ActiveWorkbook.SaveAs Filename:= _
"C:\temp\Bearbeitungsstatus.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
and I could save the file.
I modified the code below from an IF / FOR to a CASE SELECT and modified the range for FinalRow variable to be the current column used range. It looks like your For / Next statement in the sub is pseudo code so I haven't made any changes to it.
Public Sub SubstitudeFieldValues()
Sheets("Fertigstellungsgrad xx.xx.xx").Select
' Find the last row of data
'FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
FinalCol = Cells(1, Columns.Count).End(xlToLeft).Column
' Loop through each row
For Col = 1 To FinalCol
colTitle = Cells(1, Col).Value
Select Case colTitle
Case "K1", "K2", "K3", "S1", "S2", "S3", "P1", "P2", "P3", "T1", "T2", "T3", "A1", "A2", "D1", "D2"
FinalRow = Range(colTitle).End(xlDown).Row
Case else
goto NotFound
End Select
For x = 2 To FinalRow
wert = Cells(x, Col)
If wert <> Leer Then
'Range(Cells(x, Col), Cells(x, Col)).Select
Cells(x, Col).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next x
NotFound:
Next Col
End Sub
To set the name of the new sheet to include the date, you can change your code in SaveSheets() from:
Sheets("Fertigstellungsgrad aktuell (2)").Name = "Fertigstellungsgrad xx.xx.xx"
to
Sheets("Fertigstellungsgrad aktuell (2)").Name = "Fertigstellungsgrad " & Format(Now(), "dd.mm.yy")
Your subsequent Select statement in Sub SubstitudeFieldValues() would become:
Public Sub SubstitudeFieldValues()
Sheets("Fertigstellungsgrad " & Format(Now(), "dd.mm.yy").Select
Related
I've created a macro to get data from active workbook, copy it into a new one and save new file. Whole code worked perfect until I changed Office to 365 with Onedrive on my computer.
When I run this macro, I get error 1004: Premission denied in macro below
Sub create_new()
Dim SheetI As Worksheet
Dim SheetO As Worksheet
Dim BookO As Workbook
Dim BookI As Workbook
Dim row As Long
Dim i As Long
Dim dict As Object
Dim path As String
Dim brng As Range
Dim found As Boolean
path = CreateObject("WScript.Shell").SpecialFolders("MyDocuments") & "\path\"
If Len(Dir(path, vbDirectory)) = 0 Then MkDir path
path = path & _
Format(Date, "ddmmmyyyy") & ".xlsx"
If Dir(path) <> "" Then Kill path
Set BookI = ThisWorkbook
Set BookO = Workbooks.Add
With BookO
BookO.Sheets.Add.Name = "Name"
Set SheetO = BookO.Sheets("Name")
SheetO.Cells(1, 1).Value = "1"
SheetO.Cells(1, 2).Value = "2"
SheetO.Cells(1, 3).Value = "3"
SheetO.Columns("A:H").AutoFit
SheetO.Range("a1:h1").Font.Bold = True
Application.DisplayAlerts = False
.SaveAs path
Application.DisplayAlerts = True
End With
Set dict = SubTotals(BookI)
For Each SheetI In BookI.Sheets
If SheetI.Name <> "Dane" Then
For row = 10 To SheetI.Cells(Rows.Count, 1).End(xlUp).row Step 1
If i <= row Then
If SheetI.Cells(row, 2).Value = "Oprysk" Then
If Not found Then found = True
i = row
If SheetI.Cells(row, 2).MergeCells Then i = row + SheetI.Cells(row, 2).MergeArea.Rows.Count - 1
With BookO
Range(SheetI.Cells(row, 1), SheetI.Cells(i, 1)).Copy
SheetO.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range(SheetI.Cells(row, 5), SheetI.Cells(i, 8)).Copy
SheetO.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
SheetI.Cells(2, 2).Copy
SheetO.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
SheetI.Cells(3, 5).Copy
SheetO.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
SheetO.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).Value = SearchDict(dict, SheetO.Cells(Rows.Count, 3).End(xlUp).Value)
If i <> row Then
For l = 1 To 8 Step 1
If l <> 6 And l <> 7 Then
Application.DisplayAlerts = False
Range(SheetO.Cells(Rows.Count, l).End(xlUp), SheetO.Cells(Rows.Count, l).End(xlUp).Offset(i - row, 0)).Merge
Application.DisplayAlerts = True
End If
Next l
End If
End With
End If
End If
Next row
End If
Next SheetI
If found Then
Set brng = Range(SheetO.Cells(1, 1), SheetO.Cells(Rows.Count, 6).End(xlUp).Offset(0, 2))
With BookO
brng.BorderAround xlContinuous, xlThin
brng.Borders(xlInsideHorizontal).LineStyle = xlContinuous
brng.Borders(xlInsideVertical).LineStyle = xlContinuous
Application.DisplayAlerts = False
.SaveAs path
Application.DisplayAlerts = True
End With
MsgBox "File saved in path: " & path
Else
With BookO
Application.DisplayAlerts = False
BookO.Close
Application.DisplayAlerts = True
End With
Kill path
MsgBox "Data not found"
End If
End Sub
So basicly I check here if the path and file exists. If not, its created. I save the new workbook for the first time when its formated but before data is copied. Secondly its saved when the data is copied and this second attempt to save workbook fails with error above. Why I was able to overwrite this workbook when I didnt use Onedrive and now, when I do it shows me the error?
When trying to run the below code, a compile error of for without next or next without for is experienced. The error message keeps appearing in loops (once a for without next error, the next time a next without for error), making it difficult to spot where the error is.
How to check if an "end if" is missing or if there is an indentation error?
Please help!
Sub DataCleaning()
Dim ws As Worksheet
Dim myValue As Variant
Dim StringToFind As String
Dim f, cell, cell1 As Range
Dim LastCol, LastCol1 As Long
Dim i, j, k, l As Integer
Application.DisplayAlerts = False 'Optional
For Each ws In Worksheets
Select Case ws.Name
'Include sheet names to keep on next line (with comma between)
Case "VIE", "CA", "UK", "EU", "CHN", "JP", "AU", "NZ", "KR", "PH", "TH", "ID"
ws.Cells.ClearFormats
Case Else
ws.Delete
End Select
Next ws
Application.DisplayAlerts = True
StringToFind = Application.InputBox("Input Batch Number:")
For Each ws In Worksheets
'myValue = InputBox("Input Batch Number:", ws, 1)
ws.Activate
ActiveSheet.Rows(4).Select
Set cell = Selection.Find(what:="Batch " & StringToFind, After:=ActiveCell, _
LookIn:=xlFormulas, lookat:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If cell Is Nothing Then
MsgBox "No Order"
Else
cell.Offset(0, -1).Select
ColumnLetter = Split(Cells(1, ActiveCell.Column).Address, "$")(1)
Range(Columns("B"), Columns(ColumnLetter)).EntireColumn.Delete
LastCol = Cells(5, Columns.Count).End(xlToLeft).Column
ws.Activate
ActiveSheet.Rows(5).Select
Set cell1 = Selection.Find(what:="<", After:=ActiveCell, _
LookIn:=xlFormulas, lookat:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
cell1.Select
ColumnLetter1 = Split(Cells(1, ActiveCell.Column).Address, "$")(1)
Range(Cells(1, ColumnLetter1), Cells(1, LastCol)).EntireColumn.Delete
Rows(1).EntireRow.Delete
Range("A1") = "Batch"
Range("A2") = "City"
Range("A3") = "Number"
Range("A4") = "Shipment"
LastCol1 = Cells(4, Columns.Count).End(xlToLeft).Column
With Range("B1")
For j = 2 To LastCol1
Cells(1, j) = StringToFind
Next j
End With
With Range("B2")
For k = 2 To LastCol1
Cells(2, k) = ws.Name
Next k
End With
With Range("B3")
For l = 2 To LastCol1
Cells(3, l) = ""
Next l
End With
Cells(4, LastCol1 + 1) = "Price"
i = 1
Do While Not IsEmpty(Cells(i, 1))
SKUColumn = Cells(i, 1)
If SKUColumn Like "2018" Then
ws.Rows([i]).EntireRow.Delete
Deleted = True
ElseIf SKUColumn Like "2020" Then
ws.Rows([i]).EntireRow.Delete
Deleted = True
ElseIf SKUColumn Like "Accessories" Then
ws.Rows([i]).EntireRow.Delete
Deleted = True
End If
i = i + 1
Loop
Application.ScreenUpdating = True
ws.Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\xxx\Desktop\" & ws.Name & ".csv" _
, FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=True
Application.ScreenUpdating = False
Next ws
End If 'this line should be in front of `Next ws`
I made this sub in VBA which copies the contents of a sheet to a new sheet, then format and save this as a .csv. But when I'm debugging this, the sub jumps alone to a function in another module and starts an infinite loop.
Depending on the organization of the commands, it jumps before or after for this function, but always skips.
in the current sub is jumping in the ".move" command.
I have not found the solution because the polls always return something like: "How to do a sub automatically call a function?" But that is precisely what is happening to me without my will.
That is my Sub
Sub TCzor()
'
Dim MData, MStr
Dim ultimalinha As Integer
Dim valorA As String
Dim valorB As String
Dim valorC As String
Dim valorD As String
Dim sUserName As String
MData = Date
MStr = Format(MData, "ddmm")
sUserName = Environ$("username")
'
Windows("MultiTrat.xlsm").Activate
Sheets("MultiTrat").Select
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = "TCzor"
Sheets("MultiTrat").Select
Range("AX3:BF111").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("TCzor").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("$A$1:$I$109").AutoFilter Field:=1, Criteria1:="="
Rows("2:2").Select
Range(Selection, Rows("1000:1000")).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("G:G").Select
Selection.Cut
Columns("B:B").Select
ActiveSheet.Paste
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Range(Selection, Columns("XFD:XFD")).Select
Selection.Delete Shift:=xlToLeft
Range("D1").Value = "Valor"
Columns("D:D").Select
Selection.NumberFormat = "0.00"
ultimalinha = Range("A1").End(xlDown).Row
For linha = 2 To ultimalinha
If Cells(linha, 3).Value = "C" Then
Cells(linha, 3).Value = "Créd"
Else
Cells(linha, 3).Value = "Déb"
End If
Next linha
For linha = 1 To ultimalinha
valorA = Cells(linha, 1)
valorB = Cells(linha, 2)
valorC = Cells(linha, 3)
valorD = Cells(linha, 4)
Cells(linha, 1) = valorA & ";" & valorB & ";" & valorC & ";" & valorD
Next linha
Range("B:D").Delete
Sheets("TCzor").Select
Sheets("TCzor").Move
ChDir "C:\Users\" & sUserName & "\Desktop"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\" & sUserName & "\Desktop\TC" & MStr & ".csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveWindow.Close
Windows("tczor_jv.xlsm").Activate
End Sub
And this is the Function that it is calling by itself
Function GetARN(Myrange As Range) As String
Dim regex As New RegExp
Dim strPattern As String
Dim strInput As String
Dim strReplace As String
Dim strOutput As String
strPattern = "[0-9]{23}"
strInput = Myrange.Value
With regex
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
Set matches = regex.Execute(strInput)
For Each Match In matches
GetARN = Match.Value
Next Match
I know variations of this question have been asked but I can't seem to find the right code to accomplish this task. I have 2 tabs, Master Summary and Master Detail, from which I would like to copy data based on cell values in columns K and G respectively. I would like to copy data from both tabs into a new workbook if the values where these columns match. Each value needs its own workbook to be saved as the name in the cell.
Thanks
Here is what I came up with:
Sub CopyCMOsToOwnWorkbooks()
Application.EnableCancelKey = xlDisabled
Application.ScreenUpdating = False
Dim CMO As Variant
Dim CMOS As Variant
Dim wbDest As Workbook
Dim RAF As Workbook
Set RAF = ThisWorkbook
Dim rng As Range
Set rng = Range(Range("A1"), Range("A1").SpecialCells(xlLastCell))
CMOS = Array("Element Care", "CCACG EAST", "SCMO", "CCACG WEST", "Uphams Corner Hlth Cent", "CCC-Boston", "Vinfen", "Behavioral Hlth Ntwrk", _
"CommH Link Worc", "Long Term Care CMO", "Advocates, Inc", "CCC-Springfield", "BU Geriatric Service", "Lynn Comm HC", "CCA-BHI", "BIDJP Subacute", _
"CCC-Lawrence", "CCC-Framingham", "East Boston Neighborhoo", "BosHC 4 Homeless", "Bay Cove Hmn Srvces", "Mailhoit, Carrie", "Brightwood Hlth Ctr-Bay", _
"Romero, Michele", "Isaacs, Cindy", "McCoy, Viola", "ADRC of Greater North Shore", "Geller, Marian")
For Each CMO In CMOS
On Error Resume Next
RAF.Activate
Application.CutCopyMode = False
Sheets("MASTER Summary").Select
Range("F12").Select
Selection.AutoFilter
ActiveSheet.ListObjects("Table_Query_from_ProdServerP052").Range.AutoFilter _
Field:=11, Criteria1:=CMO
Cells.Select
Selection.Copy
Set wbDest = Workbooks.Add(xlWBATWorksheet)
ActiveSheet.Paste
ActiveSheet.Cells.Select
Selection.ColumnWidth = 8.29
Cells.EntireColumn.AutoFit
Selection.ColumnWidth = 78.71
Cells.EntireRow.AutoFit
Cells.EntireColumn.AutoFit
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Summary"
Range("C24").Select
ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes).Name = _
"Table1"
Range("Table1[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight13"
RAF.Activate
Application.CutCopyMode = False
Sheets("MASTER Detail").Select
Range("A2").Select
Selection.AutoFilter
ActiveSheet.ListObjects("Table_Query_from_ProdServerP054").Range.AutoFilter _
Field:=7, Criteria1:=CMO
Cells.Select
Selection.Copy
wbDest.Activate
Sheets.Add After:=ActiveSheet
Range("A1").Select
ActiveSheet.Paste
Cells.Select
Selection.ColumnWidth = 34.29
Selection.ColumnWidth = 50.71
Cells.EntireRow.AutoFit
Cells.EntireColumn.AutoFit
wbDest.Sheets("Sheet2").Select
wbDest.Sheets("Sheet2").Name = "Detail"
ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes).Name = _
"Table2"
Range("Table2[#All]").Select
ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight13"
Range("A13").Select
wbDest.Sheets("Summary").Select
Application.DisplayAlerts = False
wbDest.SaveAs ThisWorkbook.Path & Application.PathSeparator & _
CMO & " " & Format(Date, "mmm_dd_yyyy")
Application.DisplayAlerts = True
wbDest.Close
Next CMO
End Sub
I'm having trouble with the Range function. (Nearly) completed code below. I'm fairly new to VBA, so please explain the basics if you have the time. This is the line that is giving me a debug error:
Set CombinedPropRange = ThisWorkbook.Worksheets("PropFiltered").Range("A" & _
PropACount & ":J" & SplitTabName(2))
Full Code Below:
Sub FillTabsTest()
' FillTabsTest Macro
HowManyTabsDoYouNeed = 4 'If you want to add or remove Tabs, you must change this number AND add/subtract from the "TabName(1)" section below.
ReDim TabName(1 To HowManyTabsDoYouNeed) As String
'Grabs Data from Original Workbook and creates a new Workbook.
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A1:P1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Call WrapText
TabName(1) = "April H.,0,1000"
TabName(2) = "Christopher H.,0,1000"
TabName(3) = "Christie E.,500,500"
TabName(4) = "Cori M.,500,500"
'Places Filtered Auto Events on its own tab
Sheets("Sheet1").Select
Cells.Select
Selection.AutoFilter
ActiveSheet.Range("$A:$S").AutoFilter Field:=8, Criteria1:="=COMAUTO", _
Operator:=xlOr, Criteria2:="=PERSAUTO"
ActiveSheet.Range("$A:$S").AutoFilter Field:=5, Criteria1:="=3*", Operator _
:=xlAnd
ActiveSheet.Range("$A:$S").AutoFilter Field:=9, Criteria1:=Array( _
"AUTO BODILY INJURY", "AUTO MED PAY", "AUTO PROPERTY DAMAGE", "AUTO-ENDORSEMENT", _
"AUTO-OTHER", "BODILY INJURY", "COLLISION", "COMPREHENSIVE", "LIABILITY", "OTHER", _
"RENTAL REIMBURSEMENT", "UM/UIM"), Operator:=xlFilterValues
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "AutoFiltered"
ActiveSheet.Paste
'Places Filtered Property Events on its own tab
Sheets("Sheet1").Select
Cells.Select
Application.CutCopyMode = False
ActiveSheet.ShowAllData
Cells.Select
ActiveSheet.Range("$A:$S").AutoFilter Field:=8, Criteria1:="=COMPROP", _
Operator:=xlOr, Criteria2:="=PLPROP"
ActiveSheet.Range("$A:$S").AutoFilter Field:=5, Criteria1:="=3*", Operator _
:=xlAnd
ActiveSheet.Range("$A:$S").AutoFilter Field:=12, Criteria1:="<>*FIRE*", _
Operator:=xlOr, Criteria2:="<>*SMOKE*"
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "PropFiltered"
ActiveSheet.Paste
'Begin adding the above named tabs to the workbook
For i = 1 To HowManyTabsDoYouNeed
Sheets.Add After:=Sheets(Sheets.Count)
SplitTabName = Split(TabName(i), ",")
ActiveSheet.Name = SplitTabName(0)
Next i
'Begin populating employee's sheets.
Dim AutoACount As Integer
Dim PropACount As Integer
' Dim AutoAPasteCount As Integer
Dim PropAPasteCount As Integer
Dim AutoJCount As Integer
Dim PropJCount As Integer
'Dim AutoRangeA As Range
'Dim AutoRangeJ As Range
'Dim PropRangeA As Range
'Dim PropRangeJ As Range
Dim PropAPasteCountRange As String
Dim CombinedPropRange As Range
Dim CombinedAutoRange As Range
AutoACount = 2
PropACount = 2
AutoJCount = 2
PropJCount = 2
PropAPasteCount = 2
For i = 1 To HowManyTabsDoYouNeed
SplitTabName = Split(TabName(i), ",")
If SplitTabName(1) <> "0" Then
' Set AutoRangeA = Range("A" & AutoACount)
' Set AutoRangeJ = Range("J" & SplitTabName(1))
Sheets("AutoFiltered").Select
Set CombinedAutoRange = ThisWorkbook.Worksheets("AutoFiltered").Range("A" & AutoACount & ":J" & SplitTabName(1))
CombinedAutoRange.Copy
Sheets("SplitTabName(0)").Select
ActiveSheet.Paste
AutoACount = AutoACount + SplitTabName(1)
PropAPasteCount = SplitTabName(1)
End If
If SplitTabName(2) <> "0" Then
'Set PropRangeA = Range("A" & PropACount)
'MsgBox PropRangeA
'Set PropRangeJ = Range("J" & SplitTabName(2))
PropAPasteCountRange = "A" & PropAPasteCount
'Sheets("PropFiltered").Select
Set CombinedPropRange = ThisWorkbook.Worksheets ("PropFiltered").Range("A" & PropACount & ":J" & SplitTabName(2))
CombinedPropRange.Copy
Sheets("SplitTabName(0)").Select
ThisWorkbook.Worksheets(SplitTabName(0)).Cells(PropAPasteCountRange).Select
ActiveSheet.Paste
PropACount = PropACount + SplitTabName(2)
End If
Next i
End