Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
random cells in a row
I think this is rather simple but I just don't have the brain power to
figure it out. I have two row in a excel spread sheet data info- sheet 5-rows A and B in these rows there will be radomly placed numbers that I need to get to go into a sread sheet. I tried autofilter and it works if I manually want to do it but I would liek to set up this so a macro can do it. Any ideas? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
random cells in a row
How many different numbers will need to be moved to the spread sheet?
Are the numbers in both columns A and B of the sheet where they are randomly located? Where do you want them put on the spread sheet? Down a column? Across a row? Does the number of items in Columns A and B of the sheet with the radomly located numbers vary in length or is it a fixed range such as A2:B100? Are the numbers formatted as numbers or text? How do you want them formatted in the spread sheet? " wrote: I think this is rather simple but I just don't have the brain power to figure it out. I have two row in a excel spread sheet data info- sheet 5-rows A and B in these rows there will be radomly placed numbers that I need to get to go into a sread sheet. I tried autofilter and it works if I manually want to do it but I would liek to set up this so a macro can do it. Any ideas? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
random cells in a row
There can be as little as 1 in A and 1 in B and as high as 10 in A and
10 in B If I could get them to the top of C and D in the same sheet I can do the rest. The other factor that I require is lets say there is a number in A:137 and A:3000, I want the number in A137 at the very top and I need the same of B. Am I making any sence? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
random cells in a row
I guessed a lot about what you really need, but maybe this will do what you
want. If it does not, just do a new posting and describe what else you need. I assume you know to copy this code to your VBA code module and then assign it to a macro control of some type. Sub moveNumb() lastRow = Worksheets(1).UsedRange.SpecialCells(xlCellTypeLas tCell) _.Row + 1 For i = 1 To lastRow If Cells(i, 1) < "" And IsNumeric(Cells(i, 1)) Then Cells(i, 1).Copy Worksheets(2).Activate If Cells(1, 1) = "" Then ActiveSheet.Cells(1, 1).PasteSpecial Paste:=xlValues Else Worksheets(2).Cells(Cells(Rows.Count, 1).End(xlUp) _.Row + 1, 1).PasteSpecial Paste:=xlValues End If Worksheets(1).Activate End If If Cells(i, 2) < "" And IsNumeric(Cells(i, 2)) Then Cells(i, 2).Copy Worksheets(2).Activate If Cells(1, 2) = "" Then ActiveSheet.Cells(1, 2).PasteSpecial Paste:=xlValues Else Worksheets(2).Cells(Cells(Rows.Count, 2).End(xlUp) _.Row + 1, 2).PasteSpecial Paste:=xlValues End If Worksheets(1).Activate End If Next Application.CutCopyMode = False End Sub " wrote: There can be as little as 1 in A and 1 in B and as high as 10 in A and 10 in B If I could get them to the top of C and D in the same sheet I can do the rest. The other factor that I require is lets say there is a number in A:137 and A:3000, I want the number in A137 at the very top and I need the same of B. Am I making any sence? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
random cells in a row
This might work better. I re-read your explanation and saw that you want it
on the same sheet. Sub moveNumbs() lastRow = Worksheets(1).UsedRange.SpecialCells(xlCellTypeLas tCell).Row + 1 For i = 1 To lastRow If Cells(i, 1) < "" And IsNumeric(Cells(i, 1)) Then Cells(i, 1).Copy If Cells(1, 3) = "" Then ActiveSheet.Cells(1, 3).PasteSpecial Paste:=xlValues Else Cells(Cells(Rows.Count, 3).End(xlUp).Row + 1, 3).PasteSpecial Paste:=xlValues End If End If If Cells(i, 2) < "" And IsNumeric(Cells(i, 2)) Then Cells(i, 2).Copy If Cells(1, 4) = "" Then ActiveSheet.Cells(1, 4).PasteSpecial Paste:=xlValues Else Cells(Cells(Rows.Count, 4).End(xlUp).Row + 1, 4).PasteSpecial Paste:=xlValues End If End If Next Application.CutCopyMode = False End Sub " wrote: There can be as little as 1 in A and 1 in B and as high as 10 in A and 10 in B If I could get them to the top of C and D in the same sheet I can do the rest. The other factor that I require is lets say there is a number in A:137 and A:3000, I want the number in A137 at the very top and I need the same of B. Am I making any sence? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I sum up random cells | Excel Worksheet Functions | |||
How to select other random cells | Excel Worksheet Functions | |||
#Value in random cells | Excel Worksheet Functions | |||
random merged cells | Excel Discussion (Misc queries) | |||
fill random cells | Excel Programming |