VBA for Excel
VBA is awesome, I love it. What I don’t love is scratching through old Macros to pick up a piece of code that I know does just what I need. I have tried Gist with Git, but I just have not bonded with it. So I am wondering can the Word Press search function assist me here? This is my experiment to store snippets and see if I do pick them up again later.
Stitching sheets together
Option Explicit Sub populatePrices() 'first copy HCWF sheet Sheets("HCWF").Select Call grabLastRow Call pasteFirst 'then copy Multisnack Sheets("Multisnack").Select Call grabLastRow Call pasteNotFirst End Sub Sub grabLastRow() Dim lastRow As Integer 'grab from active sheet lastRow = Range("A" & Rows.Count).End(xlUp).Row 'MsgBox "last row found is" & lastRow Range("A2:C" & lastRow).Select End Sub Sub pasteFirst() 'MsgBox "About to paste" Selection.Copy Sheets("Prices").Select Range("A2").Select ActiveSheet.Paste End Sub Sub pasteNotFirst() Dim lastRow As Integer Selection.Copy Sheets("Prices").Select 'Find first empty cell lastRow = Range("A" & Rows.Count).End(xlUp).Row Range("A" & lastRow + 1).Select ActiveSheet.Paste End Sub |