Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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
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
How do I sum up random cells Josh W Excel Worksheet Functions 25 April 2nd 23 07:56 PM
How to select other random cells Chad Excel Worksheet Functions 0 April 23rd 10 02:49 PM
#Value in random cells Michael Excel Worksheet Functions 2 June 19th 09 06:31 PM
random merged cells grant1 Excel Discussion (Misc queries) 0 July 24th 08 05:19 PM
fill random cells hulub Excel Programming 1 September 19th 04 08:26 PM


All times are GMT +1. The time now is 04:07 AM.

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

About Us

"It's about Microsoft Excel"