noboffinme
New Member
- Joined
- Jun 30, 2011
- Messages
- 13
Hi
I have 2 w/shts, 'A' & 'B', W/sht 'A' has a column 'A' of Numbers where each number appears at least twice.
In column 'C' on the same w/sht 'A' there are values I want to hold as variables to be pasted onto W/sht 'B' against that same number.
So I have some code that selects a number from W/sht 'B' & goes over to W/sht 'A' to search column 'A' for the first occurrence of that number.
Once the code finds the number, it saves the value in the same Row on Column 'C' as a variable.
My problem is getting the code to then go & find the next occurence of the same number, go to the Column 'C' value & save that as a variable etc etc until I have all the variables for that number.
I use such variables as 'planx' & 'plan1' etc to hold the variable value.
I recorded a macro to do a 'Find' & 'FindNext' function & am trying to adapt it for what I need.
The first Find is OK & the address of the Column 'C' value id held, however when I go to the FindNext line of code - I firstly get an 'Object Variable not set' error. When I try to fix this by adding the 'what:= .... ' part of the criteria, I get the 448 error.
Can anyone advise what I could do to fix this OR suggest a better way to do what I want to do?
Below is the code throwing the error, Thanks;
#################################################
Recorded code. works OK;
Selection.Find(what:=acno, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
----------------------------------------------------------------
My additonal code is next to hold the variable address, works OK;
ActiveCell.Offset(0, f).Select
planx = ActiveCell.Address
plan1 = planx
planx = ""
As soon as I get to this line below (after I added the 'what:=acno,' part, I get the # 448 error.
-------------------------------------------------------------
Selection.FindNext(what:=acno, After:=ActiveCell).Activate
-------------------------------------------------------------
My code again next to hold the variable
ActiveCell.Offset(0, f).Select
planx = ActiveCell.Offset(0, f).Value
plan2 = planx
planx = ""
I have 2 w/shts, 'A' & 'B', W/sht 'A' has a column 'A' of Numbers where each number appears at least twice.
In column 'C' on the same w/sht 'A' there are values I want to hold as variables to be pasted onto W/sht 'B' against that same number.
So I have some code that selects a number from W/sht 'B' & goes over to W/sht 'A' to search column 'A' for the first occurrence of that number.
Once the code finds the number, it saves the value in the same Row on Column 'C' as a variable.
My problem is getting the code to then go & find the next occurence of the same number, go to the Column 'C' value & save that as a variable etc etc until I have all the variables for that number.
I use such variables as 'planx' & 'plan1' etc to hold the variable value.
I recorded a macro to do a 'Find' & 'FindNext' function & am trying to adapt it for what I need.
The first Find is OK & the address of the Column 'C' value id held, however when I go to the FindNext line of code - I firstly get an 'Object Variable not set' error. When I try to fix this by adding the 'what:= .... ' part of the criteria, I get the 448 error.
Can anyone advise what I could do to fix this OR suggest a better way to do what I want to do?
Below is the code throwing the error, Thanks;
#################################################
Recorded code. works OK;
Selection.Find(what:=acno, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
----------------------------------------------------------------
My additonal code is next to hold the variable address, works OK;
ActiveCell.Offset(0, f).Select
planx = ActiveCell.Address
plan1 = planx
planx = ""
As soon as I get to this line below (after I added the 'what:=acno,' part, I get the # 448 error.
-------------------------------------------------------------
Selection.FindNext(what:=acno, After:=ActiveCell).Activate
-------------------------------------------------------------
My code again next to hold the variable
ActiveCell.Offset(0, f).Select
planx = ActiveCell.Offset(0, f).Value
plan2 = planx
planx = ""