How to find the unique cell value?

A

A. Karatas

I build the following code to search from a searchrow (PG_Begin) in
sheet assumptions with a loop. I notice that cells.find doesn't find
a unique cell and I want to know what code I must use to let the macro
find the unique cellvalue requested?? For example, if the searchvalue
is net_val-1 the copied column is net_val-1_YTD which is ofcourse not
the column I wanted to be copied.


Sub CommandButton3_Click()



On Error GoTo ErrorHandler

Application.ScreenUpdating = False

Application.Goto Reference:="PG_Begin"
Row = ActiveCell.Row

While ActiveSheet.Cells(Row, 1).Value <> ""
PG = ActiveSheet.Cells(Row, 1).Value


Sheets("olap").Select
Cells.Find(What:=PG, After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Activate

ActiveCell.EntireColumn.Select

ActiveCell.EntireColumn.Copy

ActiveSheet.Paste
(Sheets("extract").Range("ia1").End(xlToLeft).Offset(, 1))

Sheets("Assumption").Select

Row = Row + 1

Wend

Sheets("extract").Select
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft


MsgBox ("correcting OLAP extract completed")

ErrorHandler:
Application.ScreenUpdating = True
MsgBox (Err.Description)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top