Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
equal size columns [same no. of rows]
hello everyone
i want to ask a question tried to slove them but as i m novice so havnt solved so far i have data in column1 to n the data in each is of different length/ diff number of rows are present i want to make all coulumns are of same size say if 1 column has data in 15 rows n another column2 hav data in 6 rows [so i want to copy data of 6 row in all the rows upto 15] and some other column hav data in 10 rows ..[so i want to copy data of 6 row in all the coumns upto 15] so want them to make equal length |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
equal size columns [same no. of rows]
non-vba - just drag down the last cell (say, row 6) to where you need
to go (row 15), thereby autofilling. in vba (untested), something like sub fill_all_rows() dim col as integer dim c as range dim iLastRow as integer dim rmyrange as range set rmyrange = worksheet.range("a1:f15") 'for instance set col = 1 for each col in rmyrange do until c.row = 16 for each c in col if c <"" then 'do nothing else c = c.offset(-1,0).value 'might need to be c.value = c.offset(-1,0).value end if next c next col end sub hope it (at least) gets you started! :) susan On May 9, 8:33 am, wrote: hello everyone i want to ask a question tried to slove them but as i m novice so havnt solved so far i have data in column1 to n the data in each is of different length/ diff number of rows are present i want to make all coulumns are of same size say if 1 column has data in 15 rows n another column2 hav data in 6 rows [so i want to copy data of 6 row in all the rows upto 15] and some other column hav data in 10 rows ..[so i want to copy data of 6 row in all the coumns upto 15] so want them to make equal length |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
equal size columns [same no. of rows]
thanks susan for ur time n quick reply
but actually the code u mentioned woked only in case of 2 columns in which col1 col2 but in my case many columns are there and i mean we hav to "redim" the size of our range i have to compare two adjacent columns and count whichevr have greater number of rows between two adjacent column then i hav to make small size column should b equal to longer column hope i hav made it clear plz let me knw if i havnot frmed it properly many thanx for ur time n sugeestions |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
equal size columns [same no. of rows]
hi! sorry i didn't get back to you yesterday - i was out sick........
i am still sick today & my brain is not working quite good enough, and i can't make this stupid thing work................. i couldn't make 2 "for-each" loops work inside each other, so i made the 2nd loop into a different sub. maybe somebody else can help you get it working??? :P sorry! susan '====================== Option Explicit Sub fill_all_rows() Dim col As Integer Dim myCol As Range Dim c As Range Dim ic As Integer Dim iLastRow As Integer Dim rmyRange As Range Dim ws As Worksheet Set ws = ActiveSheet Set rmyRange = ws.Range("a1:f15") 'for instance Set myCol = ws.Cells(, 1) For Each myCol In rmyRange Call loop_columns Next myCol End Sub '========================== Sub loop_columns() Dim col As Integer Dim myCol As Range Dim rCell As Range Dim r As Long Dim ic As Integer Dim iLastRow As Integer Dim rmyRange As Range Dim ws As Worksheet ic = 1 For Each rCell In myCol r = rCell.Row Do Until r = 16 If rCell < "" Then 'do nothing Else rCell = rCell.Offset(-1, 0).Value 'might need to be c.value = 'c.Offset(-1, 0).Value End If Loop Next rCell End Sub '======================== On May 9, 1:42 pm, wrote: thanks susan for ur time n quick reply but actually the code u mentioned woked only in case of 2 columns in which col1 col2 but in my case many columns are there and i mean we hav to "redim" the size of our range i have to compare two adjacent columns and count whichevr have greater number of rows between two adjacent column then i hav to make small size column should b equal to longer column hope i hav made it clear plz let me knw if i havnot frmed it properly many thanx for ur time n sugeestions |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Columns of Equal Size | Excel Discussion (Misc queries) | |||
Zoom size doesn't equal print size | Excel Discussion (Misc queries) | |||
Hide rows when specified columns equal zero | Excel Discussion (Misc queries) | |||
Turning rows of equal number of columns into 1 continuous row | Excel Worksheet Functions | |||
set number of rows equal in mutiple columns | Excel Discussion (Misc queries) |