VBA to copy a dynamic range to clipboard

Purplemuffin

New Member
Joined
Nov 24, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi.

I'm trying and failing to get my head around VBA so thought I'd ask here.

I'm trying to write some VBA to attach to a button so that the user can copy a specific range of cells to clipboard in order to paste elsewhere.

This is the basic of my code:

Sub Copy_Test()
Range("A36:F39").Copy
End Sub

However - where it says F39, this could be anywhere between F38 and F50, where the row is taken to be the last non blank row (it would also have TOTAL in column E if that means the code is easier to write?)

Any ideas anybody please?
 
No - I just want to copy the cells that have something in them. These are cells that automatically populate from other data but could be anywhere from 3 rows to about 30 rows tall. All cells will have formula in though, in the form =IF(A3<>"", A3, "") (or variants on this)
Ok. I will most definitely need to see a copy of the Sheet for this. However, removing Blanks will change the structure of the Range. So, if you have categorized Columns, the data may be moved from one Column to another.
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

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