Resize Range

doug.washburn

New Member
Joined
May 18, 2004
Messages
49
Hi,

I have a macro that takes an active cell, resizes the selection and then copies and transposes that data onto a secon sheet.


ActiveCell.Resize(1, 28).copy
Sheets("transposed data").Select
Range("B4").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

Now I need to use the same macro but instead of re-sizing a single cell, the user could select 1, 2, 3 or more cells in a column and I need to resize their selection across 28 columns.

Any ideas?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
First off some housekeeping:

Code:
ActiveCell.Resize(1, 28).copy 
Sheets("transposed data").Range("B4").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ 
False, Transpose:=True

Thus this may get what you are looking for:

Code:
Sub Test1()

Dim LstCol As Long
For Each c In Selection
    c.Resize(1, 28).Copy
    LstCol = Sheets("Transposed Data").Cells(4, Columns.Count).End(xlToLeft).Column + 1
    Sheets("transposed data").Cells(4, LstCol).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
Next c

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,957
Latest member
Hat4Life

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