Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / July 2007

Tip: Looking for answers? Try searching our database.

transpose skip zeros(0's)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ali - 18 Jul 2007 16:08 GMT
Hi

I am trying to transpose a row into column. I want the column to take
only non-zero and non-blank values,e.g.,

1 blank 2 0 blank 3 4

after transpose

1
2
3
4

I am using the following code:

Sub transpose_data()
Dim lastcol As Long
Dim ws As Worksheet
Set ws = Worksheets("sheet2")

lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
With ws
.Range(.Cells(1, 1), .Cells(1,
lastcol)).SpecialCells(xlCellTypeConstants).Copy

.Range("A2").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
   SkipBlanks:=False, Transpose:=True
End With
Application.CutCopyMode = False

End Sub

can somebody guide me how can i add the functionality of transposing
non-zero values only.

Thanks

ali
Rick Rothstein (MVP - VB) - 18 Jul 2007 16:38 GMT
It looks like your code works except that it keeps the 0 cell. Try adding
this line immediately after the With statement and see if it works for
you....

.Range(.Cells(1, 1), .Cells(1, lastcol)).Replace 0, ""

Rick

> Hi
>
[quoted text clipped - 35 lines]
>
> ali
Dave Peterson - 18 Jul 2007 17:23 GMT
Check your other post, too.

> Hi
>
[quoted text clipped - 35 lines]
>
> ali

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.