DataBlake
Well-known Member
- Joined
- Jan 26, 2015
- Messages
- 781
- Office Version
- 2016
- Platform
- Windows
Hello,
I have this sub from @jmacleary found on this post
but i thought i would be best to start a new post as the problem has shifted
So the sub will grab sheets from an array and put the first column of each sheet into one sheet titled "Unknown"
My problem is that the sheets are now generated based on user needs, so there may not be all 6 sheets depicted in the array.
I feel mega dumb for not being able to write a code that says if this sheetname exists continue with the code, else do nothing?
I can't get a custom function that uses boolean to work or anything.
halp
I have this sub from @jmacleary found on this post
but i thought i would be best to start a new post as the problem has shifted
So the sub will grab sheets from an array and put the first column of each sheet into one sheet titled "Unknown"
My problem is that the sheets are now generated based on user needs, so there may not be all 6 sheets depicted in the array.
I feel mega dumb for not being able to write a code that says if this sheetname exists continue with the code, else do nothing?
I can't get a custom function that uses boolean to work or anything.
halp
Code:
Sub GetColumnA()
'
'
Dim lastRow As Long
Dim SheetNames As Variant
SheetNames = Array("MTH", "WP", "MKK", "TTW", "W1", "RHH")
For Each sheetname In SheetNames
lastRow = Sheets(sheetname).Range("A" & Rows.Count).End(xlUp).Row
Sheets(sheetname).Range("A2:A" & lastRow).Copy
destrow = Sheets("Unknown").Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("Unknown").Select
Range("A" & destrow).Select
ActiveSheet.Paste
Next sheetname
End Sub