0

I am not a proficient VBA user, and I would very much appreciate your help with a relatively simple TASK:

I have made a report template using Excel. My MAIN report is on Sheet1, which has formatting but no data. I use macros to import data from .csv files, each csv file gets imported under a different sheet (i.e. Sheet2, Sheet3 etc), and then I copy values from those sheets to 'Sheet1' my MAIN. Depending on the day, my .csv data imports have a different numbers of rows. So, I need to write a Macro that flexibly selects the data range in the input sheet to capture all the data for the day. Then I need to paste this selection to 'Sheet1' but only paste values so I can keep the formatting in MAIN but populate with data from Sheet2/ Sheet3 etc. Right now, I have something like this:

Sub CopyDynamic()
    Worksheets("Sheet2 ").UsedRange.Copy
    Worksheets("Sheet1").Range("B12").PasteSpecial Paste:=xlPasteValues
End Sub

Note: Inputs form Sheet2 will always have the same amount of columns and I will always wish for them to be pasted referenced to the same leftmost top cell (B12), but I do not know the exact size of the selection as the number of rows changes, so I cannot just fix the range at say: Range(“B12:C21”)

BigBen
  • 46,229
  • 7
  • 24
  • 40

0 Answers0