LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Macro to transpose data to fill blank cells in table

Hi,
I note you made changes to the statement"lastrow= .." and the "For R
= " loop. Without seeing an example of your data, I am not sure if these work
or whether my original would. My original logic worked on the premise that
there are blanl cells to act as "end of data" markers.

Can you send me an example spreadsheet to look at?
)


"nospaminlich" wrote:

Hi

Thanks a lot for your help with this. I think I'm nearly there now.

Because my table is in the middle of a sheet with other data a few rows
above, below and in columns to the right the code was copying data from
beyond my table. After a lot of trial and error (all part of my giant
learning curve) I've modified the code so it seems to do exactly what I want
except when it gets to the bottom right cell it continues the process and
doesn't recognise that it's reached the end of the table.

Do I need to put something in somewhere that says if the cell to the right
and the cell below are blank then stop? If so how would I include that in
this macro?

Sub TranposeData()

Dim lastrow As Long
Dim R As Long, C As Integer
Dim rng As Range

ActiveCell.Offset(1, 1).Activate

' Set rng = ActiveSheet.UsedRange
' Or select cell in top left corner of matrix BEFORE calling macro
Set rng = ActiveCell

lastrow = ActiveCell.End(xlDown).Row

For R = rng(1).Row To lastrow
C = Cells(R, Columns.Count).End(xlToLeft).Column
Range(Cells(R + 1, C), Cells(lastrow, C)).Copy
Cells(R, C + 1).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False, Transpose:=True
Next R

Application.CutCopyMode = False

End Sub


Thanks again for the help.

Kewa

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to fill blank cells Sunny Links and Linking in Excel 1 March 24th 06 09:09 AM
Skip blank cells on transpose in a macro Melanie O Excel Programming 2 June 22nd 05 02:41 PM
Use Autofill in a macro to fill blank cells until next text - goldyjk Excel Programming 1 June 14th 05 06:40 PM
Use Autofill in a macro to fill blank cells until next text - Bernie Deitrick Excel Programming 0 February 18th 05 06:45 PM
A macro to fill in the blank cells jer101[_3_] Excel Programming 7 June 18th 04 03:13 AM


All times are GMT +1. The time now is 02:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"