Copying Values from a Fixed Range and Pasting in a Dynamic Range

STLGuy

New Member
Joined
Feb 7, 2009
Messages
6
Hi,

I have a worksheet containing a fixed column of data, say F36:F200.

I would like a macro to copy this data and paste it into another worksheet. However, the beginning paste cell will change with each new addition of this columnar data. For example, this week the start paste cell will be A1354. Next week it will be A1405. The week after, it could be A17000. Basically, this paste location will be dynamic each new week.

I'm sure this is pretty simple if anyone can help me out.

Thanks!
 
Hi and welcome to the board!!!
Data to Copy on Sheet1. Copy to Sheet 2. Here's 1 way
Code:
Sub CopyMe()
Sheet1.Range("$F$36:$F$200").Copy Sheet2.Cells(Sheet2.Cells(Rows.Count, "A").End(xlUp).Row + 1, "A")
End Sub
Depending on your needs, there may be better (easier??) ways

lenze
 
Upvote 0
STLGuy,

The below macro will copy your fixed range in "Sheet1" to the next available row in "Sheet2". Adjust sheetnames if necessary.


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Adding the Macro
1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Option Explicit
Sub CopyFixedRange()
' hiker95, 02/21/2010
Dim NR As Long
Application.ScreenUpdating = False
NR = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row + 1
Sheets("Sheet2").Range("A" & NR & ":A" & NR + 164).Value = Sheets("Sheet1").Range("F36:F200").Value
Application.ScreenUpdating = True
End Sub


Then run the "CopyFixedRange" macro.
 
Upvote 0
Thanks, both. I was able to get it to work with a little fudging. Now, here's another one:

I have an input box where the user puts in a single date (e.g., "02/28/10"). I want my macro to take this input and paste that into a dynamic range.

Basically, I have a running tab of weekly data and am continuing to add to the existing columns. However, I don't want to change anything about what is already there. Therefore, my inputbox would need to start at the next available cell in Column B (say B1405) and copy down as far as the data to the left of it.
 
Upvote 0
To start with, maybe something like (amend the sheet name and inputbox name as needed)
Code:
Dim NxtBRw&, LstARw&
With Sheets("Sheet2")
    NxtBRw = .Cells(Rows.Count, "B").End(xlUp)(2).Row
    LstARw = .Cells(Rows.Count, "A").End(xlUp).Row
    .Range(.Cells(NxtBRw, "B"), .Cells(LstARw, "B")).Value = InputBox1
End With
I'd throw in some error trapping and such but I don't know your particulars.

Hope it helps.
 
Last edited:
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top