Select range

wildpitch

New Member
Joined
Apr 7, 2002
Messages
2
Help, please.
I've got a VB app that dumps two columns of text into an spreadsheet for formatting and tidying, before being copied back out to another app. Where I'm stuck is that it's a random ammount of text, ranging from 1 row up to 30, and always 2 columns. Everything works a treat whilst I have defined a range to select in the Excel macro. What I want to do is make the select range dynamic, so that if only 5 rows contain data, the macro only copies 5 rows. Anyone able to help please?

Thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi Wildpitch

Try this


Code:
Sheet1.Range("B1", Sheet1.Range("B65536").End(xlUp)).Copy Destination:= _
Sheet2.Range("A1")

Just change references to suit.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,530
Members
448,969
Latest member
mirek8991

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