Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 58
Default Cells.Find with a variable

Reposting since I can't find the previous question.

I have a spread sheet that contains 2 columns and multiple rows:

WORKSHEET1
ProgamName Level
Prog1 29
Prog2 27
Prog3 25
Name1 95
Name2 97
Name3 98


I want to look for all "Prog1" values in another worksheet2 (same file) and
check the cell to the right if the value is equal to "29" from value shown
above. If the 2 values match then I want to copy the entire row from
workshee2 and paste them into worksheet3 using the transpose option.
Each row would be transposed to the next empty column in worksheet3

I want to repeat this process for each row in workshee1

Is this possible ?

Thanks,

El Bee


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,311
Default Cells.Find with a variable

You'll need VBA for this.

Though there are probably other ways, here is one way.

Sub test()
Sheets(2).Activate
For Each cell In Range("A1:A100")
If cell.Value = "Prog1" _
Then
If cell.Offset(0, 1).Value = "29" _
Then
r = cell.Row
c = cell.Column
Rows(cell.Row & ":" & cell.Row).Copy
Sheets(3).Activate
Range("IV1").End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

Sheets(2).Activate
Else
End If
Else
End If
Next cell

End Sub




HTH,
Paul

--

"El Bee" wrote in message
...
Reposting since I can't find the previous question.

I have a spread sheet that contains 2 columns and multiple rows:

WORKSHEET1
ProgamName Level
Prog1 29
Prog2 27
Prog3 25
Name1 95
Name2 97
Name3 98


I want to look for all "Prog1" values in another worksheet2 (same file)
and
check the cell to the right if the value is equal to "29" from value
shown
above. If the 2 values match then I want to copy the entire row from
workshee2 and paste them into worksheet3 using the transpose option.
Each row would be transposed to the next empty column in worksheet3

I want to repeat this process for each row in workshee1

Is this possible ?

Thanks,

El Bee




  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,311
Default Cells.Find with a variable

I had some unnecessary code that I used for testing in the last one.
I've removed it in the below code.

Sub test()
Sheets(2).Activate
For Each cell In Range("A1:A100")
If cell.Value = "Prog1" _
Then
If cell.Offset(0, 1).Value = "29" _
Then
Rows(cell.Row & ":" & cell.Row).Copy
Sheets(3).Activate
Range("IV1").End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets(2).Activate
Else
End If

Else
End If

Next cell

End Sub

--

"PCLIVE" wrote in message
...
You'll need VBA for this.

Though there are probably other ways, here is one way.

Sub test()
Sheets(2).Activate
For Each cell In Range("A1:A100")
If cell.Value = "Prog1" _
Then
If cell.Offset(0, 1).Value = "29" _
Then
r = cell.Row
c = cell.Column
Rows(cell.Row & ":" & cell.Row).Copy
Sheets(3).Activate
Range("IV1").End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

Sheets(2).Activate
Else
End If
Else
End If
Next cell

End Sub




HTH,
Paul

--

"El Bee" wrote in message
...
Reposting since I can't find the previous question.

I have a spread sheet that contains 2 columns and multiple rows:

WORKSHEET1
ProgamName Level
Prog1 29
Prog2 27
Prog3 25
Name1 95
Name2 97
Name3 98


I want to look for all "Prog1" values in another worksheet2 (same file)
and
check the cell to the right if the value is equal to "29" from value
shown
above. If the 2 values match then I want to copy the entire row from
workshee2 and paste them into worksheet3 using the transpose option.
Each row would be transposed to the next empty column in worksheet3

I want to repeat this process for each row in workshee1

Is this possible ?

Thanks,

El Bee






  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 58
Default Cells.Find with a variable

Paul,

First thanks for the help!

I tried your macro and I get an error, "subscript out of range" as I step
through it. The error appears with the first statement,
"Sheets(2).Activate". I changed the (2) to the worksheets name (Ecomsec)
also the other worksheet names in your example.
I'm stumped; I would expect this error with the "For Each Cell" statement;
thinking the range was incorrect but I changed that and the error still
appears when come to the Sheets(Ecomsec) statement.

Any ideas?

Lab

"PCLIVE" wrote:

I had some unnecessary code that I used for testing in the last one.
I've removed it in the below code.

Sub test()
Sheets(2).Activate
For Each cell In Range("A1:A100")
If cell.Value = "Prog1" _
Then
If cell.Offset(0, 1).Value = "29" _
Then
Rows(cell.Row & ":" & cell.Row).Copy
Sheets(3).Activate
Range("IV1").End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets(2).Activate
Else
End If

Else
End If

Next cell

End Sub

--

"PCLIVE" wrote in message
...
You'll need VBA for this.

Though there are probably other ways, here is one way.

Sub test()
Sheets(2).Activate
For Each cell In Range("A1:A100")
If cell.Value = "Prog1" _
Then
If cell.Offset(0, 1).Value = "29" _
Then
r = cell.Row
c = cell.Column
Rows(cell.Row & ":" & cell.Row).Copy
Sheets(3).Activate
Range("IV1").End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

Sheets(2).Activate
Else
End If
Else
End If
Next cell

End Sub




HTH,
Paul

--

"El Bee" wrote in message
...
Reposting since I can't find the previous question.

I have a spread sheet that contains 2 columns and multiple rows:

WORKSHEET1
ProgamName Level
Prog1 29
Prog2 27
Prog3 25
Name1 95
Name2 97
Name3 98


I want to look for all "Prog1" values in another worksheet2 (same file)
and
check the cell to the right if the value is equal to "29" from value
shown
above. If the 2 values match then I want to copy the entire row from
workshee2 and paste them into worksheet3 using the transpose option.
Each row would be transposed to the next empty column in worksheet3

I want to repeat this process for each row in workshee1

Is this possible ?

Thanks,

El Bee







  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 58
Default Cells.Find with a variable

Paul,

You can ignore my previous post. I forgot the quote marks around the
worksheet name. doh!

El Bee

"PCLIVE" wrote:

I had some unnecessary code that I used for testing in the last one.
I've removed it in the below code.

Sub test()
Sheets(2).Activate
For Each cell In Range("A1:A100")
If cell.Value = "Prog1" _
Then
If cell.Offset(0, 1).Value = "29" _
Then
Rows(cell.Row & ":" & cell.Row).Copy
Sheets(3).Activate
Range("IV1").End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets(2).Activate
Else
End If

Else
End If

Next cell

End Sub

--

"PCLIVE" wrote in message
...
You'll need VBA for this.

Though there are probably other ways, here is one way.

Sub test()
Sheets(2).Activate
For Each cell In Range("A1:A100")
If cell.Value = "Prog1" _
Then
If cell.Offset(0, 1).Value = "29" _
Then
r = cell.Row
c = cell.Column
Rows(cell.Row & ":" & cell.Row).Copy
Sheets(3).Activate
Range("IV1").End(xlToLeft).Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

Sheets(2).Activate
Else
End If
Else
End If
Next cell

End Sub




HTH,
Paul

--

"El Bee" wrote in message
...
Reposting since I can't find the previous question.

I have a spread sheet that contains 2 columns and multiple rows:

WORKSHEET1
ProgamName Level
Prog1 29
Prog2 27
Prog3 25
Name1 95
Name2 97
Name3 98


I want to look for all "Prog1" values in another worksheet2 (same file)
and
check the cell to the right if the value is equal to "29" from value
shown
above. If the 2 values match then I want to copy the entire row from
workshee2 and paste them into worksheet3 using the transpose option.
Each row would be transposed to the next empty column in worksheet3

I want to repeat this process for each row in workshee1

Is this possible ?

Thanks,

El Bee







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
Cells.Find: Why can't I pass a variable? Rick S. Excel Discussion (Misc queries) 10 October 4th 07 07:50 PM
Right Text - Variable Find Karin Excel Discussion (Misc queries) 2 June 7th 07 03:24 PM
3 variable find and replace ncspndoc Excel Discussion (Misc queries) 4 June 30th 06 09:07 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM
How do I find the last row of data and then use that as a variable Lynn Bales New Users to Excel 3 August 4th 05 12:51 PM


All times are GMT +1. The time now is 09:01 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"