Macro to copy variable ammounts of data

Mcflea

New Member
Joined
Mar 10, 2014
Messages
4
What i would like to do is create a macro to copy data from column B and then paste the values into a table on another sheet. The Data in column B will not always be consistent. Sometimes it may be B2:B610 that has data that needs to be copied, sometimes it may just be B2:B3, and other occasions it may be B2:B374. The sheet the data is to be copied from is called "Formula" and the sheet it is to be pasted into is "Table". The values are to be copied into column A of "Table". I am fairly new to VBA and I am stumbling my way through, any help would be very much appreciated.
Thanks in advance
 

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
Try this:

Code:
Sub test()
    With Sheets("Formula")
    .Range("B2:B" & .Cells(Rows.Count, 2).End(xlUp).Row).Copy Destination:=Sheets("Table").Range("A2")
    End With
End Sub
 
Upvote 0
Hi wrightyrx7,
Appreciate the help but what appears in the past column is error #Ref! and in the cells is the formula =IF(#REF!<=D2,#REF!,""), so i suspect it is copying the formulas over rather than the values.
 
Last edited:
Upvote 0
How about this:

Code:
Sub test()
    With Sheets("Formula")
        .Range("B2:B" & .Cells(Rows.Count, 2).End(xlUp).Row).Copy
        Sheets("Table").Range("A2").PasteSpecial Paste:=xlValues, _
        Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End With
    
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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