I am way out of my element in Excel VBA. I would have organized this in a database but it is not my project.
I need to combine several worksheets from the same workbook into one worksheet. I don't need the first 2 and the last 6 worksheets so I am selecting worksheets by specific names in the macro below. I also don't expect more than 500 rows per worksheet so I'm copying B9:AL509 and ignoring blanks when pasting. This is what little I know so any suggestions for improvement are welcomed.
What I don't know is how to only copy or paste into the merged worksheet if there is a value in the first column (B) of each row. There may be content in other rows but I don't want the row if there is no data in B column.
I also have no clue how to append one row after another as the macro jumps from worksheet source to worksheet source. In the macro below, I'm just advancing 10 rows for each worksheet paste as a logic placholder, whether the original worksheet had 2 rows or 50 rows.
Can anyone clue me in to how to select only rows with a value in B column and how to paste these in order on the merged worksheet?
The macro recorder helped me get to this mess below...
I need to combine several worksheets from the same workbook into one worksheet. I don't need the first 2 and the last 6 worksheets so I am selecting worksheets by specific names in the macro below. I also don't expect more than 500 rows per worksheet so I'm copying B9:AL509 and ignoring blanks when pasting. This is what little I know so any suggestions for improvement are welcomed.
What I don't know is how to only copy or paste into the merged worksheet if there is a value in the first column (B) of each row. There may be content in other rows but I don't want the row if there is no data in B column.
I also have no clue how to append one row after another as the macro jumps from worksheet source to worksheet source. In the macro below, I'm just advancing 10 rows for each worksheet paste as a logic placholder, whether the original worksheet had 2 rows or 50 rows.
Can anyone clue me in to how to select only rows with a value in B column and how to paste these in order on the merged worksheet?
The macro recorder helped me get to this mess below...
Code:
Sheets("My first worksheet").Select
Range("B9:AL509").Select
Selection.Copy
Sheets("MERGED").Select
'select new location
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
Sheets("My second worksheet").Select
Range("B9:AL509").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("MERGED").Select
'select new location
Range("A14").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
Sheets("My third worksheet").Select
Range("B9:AL509").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("MERGED").Select
'select new location
Range("A24").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
'...