Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank You again
"Mike" wrote: Try this Sub findValue() Const whatColumn = "B" 'Change to your needs Dim i As Long ' i = 5 Starting row of data change to your needs Dim lastRow As Long Dim cellPointer As Variant lastRow = Range(whatColumn & Rows.Count).End(xlUp).Row For i = 5 To lastRow Set cellPointer = Worksheets("Sheet1").Cells(i, 2) If cellPointer = 42285 Then cellPointer.Offset(0, 3).Value = "European Trade" End If If cellPointer = 9992 Then cellPointer.Offset(0, 3).Value = "Dummy fund" End If Next i End Sub "PAG" wrote: Mike, One more question. How would I add other search criteria to the code? Such as also searching for "9992" to return the value "Dummy Fund". Thanks, Peter "Mike" wrote: Try this Sub findValue() Const whatColumn = "B" 'Change to your needs Dim i As Long 'i = 5 Starting row of data change to your needs Dim lastRow As Long Dim cellPointer As Variant lastRow = Range(whatColumn & Rows.Count).End(xlUp).Row For i = 5 To lastRow Set cellPointer = Worksheets("Sheet1").Cells(i, 2) If cellPointer = 42285 Then cellPointer.Offset(0, 3).Value = "European Trade" End If Next i End Sub "PAG" wrote: Hi Can someone please help me create a macro to search an Excel worksheet(in column B) for a cell value("42285") and return a statement("European Trade") in column "E". The data can always change and the rows of data can be up to 3,000 rows. I have the below code but it needs alot of work. Dim rowCount As Integer rowCount = ActiveSheet.UsedRange.Rows.Count Dim i As Integer For i = 1 To rowCount Range("B" & i).Select If ActiveCell.Value = "42285" Then GoTo loopAgain Else ActiveCell.Offset(0, 4) = Sheets("Sheet1").ActiveCell.Offset(6, 4) ' write code to do whatever(return your activecell.offset value) End If loopAgain: Next i End Sub Thank You Peter |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find First Non blank cell than find column header and return that value | Excel Worksheet Functions | |||
Return blank cell if 'find' statement not true | Excel Worksheet Functions | |||
Find certain text in a column and return statement | Excel Worksheet Functions | |||
Creating a macro to find duplicate names | Excel Discussion (Misc queries) | |||
macro to find a text and return a message | Excel Programming |