VBA Copy and Paste Variable Range

CW Moss

New Member
Joined
Nov 29, 2005
Messages
18
Can someone please help with this senario?

I have data in columns A, B and C. First row is a header.

The data in A and B does vary from week to week. But the two columns are always the same range.

The data in C is only takes one cell which is a date in C2.

I would like to copy C2 and paste it starting at C3 and end at the last row that A and B data ends. For example the last row for A and B data is A500 and B500 then copy C2 and paste from C3 to C500.

Remember A and B can be 500 rows one week or can be 557 the next week as this range varies.

I cannot use a fixed range of which I have already figure out how to accomplish.

I do need a solution to paste to a number of rows dependent on the range of A and B.

Thanks in advanced for your assistance
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
hi,

try this code:

Code:
Sub test()

Dim i As Integer

lastrow = ActiveSheet.UsedRange.Rows.Count

For i = 3 To lastrow
    If Cells(2, 3) <> "" Then
       Cells(i, 3) = Cells(2, 3)
    End If
Next i
End Sub

cheers bogia

EDIT: added code tags - try to use 'em ;) - Moderator
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,981
Members
448,934
Latest member
audette89

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