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

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

brian.wethington

Well-known Member
Joined
Jul 20, 2006
Messages
1,739
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
 

Forum statistics

Threads
1,181,418
Messages
5,929,793
Members
436,694
Latest member
dpatete

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
Top