LostinVA

New Member
Joined
May 23, 2018
Messages
43
Hi all -

I have a sheet (titled 'QRR Template') with multiple columns that users will be populating. On a second tab ('Extract for email'), there is a Command Button where if clicked, it copies the user data from the 'QRR Template' tab and transposes the data from row format to column format and pastes on cell B7. If the button is clicked a second time, it again copies data from the 'QRR Template' tab and transposes the data from row format to column format and pastes it at the end of the previously pasted data on row B. Where it pastes on row B is variable because it's dependent on number of rows of data from the 'QRR Template' tab.

I have the below code but it's not correct. Currently, its copying a huge range of cells (majority blank) from 'QRR Template' tab and pasting to the 'Extract for email' tab. I need it to only copy rows with data. If the user populates 5 rows worth of data, I only want it to copy/paste the 5 rows.. If there are 10 rows, copy/paste the 10 rows.. etc. Also, with this code, if the button is pressed multiple times, it's pasting below the existing data on the 'Extract for email' tab. I need it to paste at the end of the data on row B. If there are 10 columns worth of data and the button is pressed, I need it to copy the 10 rows of data from the 'QRR Template' tab, transpose from row format to column format, and paste to the 'Extract for email' tab at the end of the existing data, which would be B11.

I hope that makes sense. I'm a complete noob and am lost on how to make this work. Appreciate any help you all can provide!

Existing code for Command Button on the 'Extract for email' tab:

Private Sub CommandButton1_Click()
Sheets("QRR Template").Range("B6:AK1000").Copy
If ActiveSheet.Range("B7") = "" Then
ActiveSheet.Range("B7").PasteSpecial Transpose:=True
Else:
ActiveSheet.Range("B" & Columns.Count).End(xlUp).Offset(1).PasteSpecial Transpose:=True
End If
End Sub
 
Glad to help & thanks for the feedback
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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