Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
select row
This is my current code. It allows me to search two columns and returns
where the values are via a message box. I want to be able to select the row the values are in. Can anyone help? Private Sub CommandButton1_Click() Dim c As range Dim strF1 As String Dim strF2 As String Dim strAdd As String If UserForm3.TextBox5.Text = "" Then MsgBox "Please enter Part Number" UserForm3.TextBox5.SetFocus Exit Sub End If If UserForm3.TextBox6.Text = "" Then MsgBox "Please enter Sequence Number" UserForm3.TextBox6.SetFocus Exit Sub End If strF1 = UserForm3.TextBox5.Text strF2 = UserForm3.TextBox6.Text 'Assumes that Part numbers are in column B With ActiveSheet.range("B:B") Set c = .Find(strF1, LookIn:=xlValues, lookAt:=xlWhole) If Not c Is Nothing Then strAdd = c.Address If c(1, 2).Value = strF2 Then GoTo Notify ActiveCell.Select Else: MsgBox "Not Found" Exit Sub End If Set c = .FindNext(c) If Not c Is Nothing And c.Address < strAdd Then Do If c(1, 2).Value = strF2 Then GoTo Notify Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < strAdd End If End With Notify: MsgBox """" & strF1 & """ is next to """ & _ strF2 & """ in cells " & c.Resize(1, 2).Address Selection.EntireRow.Select End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
select row
Change this:
Selection.EntireRow.Select To this Rows(c.Row).Select Charles enyaw wrote: This is my current code. It allows me to search two columns and returns where the values are via a message box. I want to be able to select the row the values are in. Can anyone help? Private Sub CommandButton1_Click() Dim c As range Dim strF1 As String Dim strF2 As String Dim strAdd As String If UserForm3.TextBox5.Text = "" Then MsgBox "Please enter Part Number" UserForm3.TextBox5.SetFocus Exit Sub End If If UserForm3.TextBox6.Text = "" Then MsgBox "Please enter Sequence Number" UserForm3.TextBox6.SetFocus Exit Sub End If strF1 = UserForm3.TextBox5.Text strF2 = UserForm3.TextBox6.Text 'Assumes that Part numbers are in column B With ActiveSheet.range("B:B") Set c = .Find(strF1, LookIn:=xlValues, lookAt:=xlWhole) If Not c Is Nothing Then strAdd = c.Address If c(1, 2).Value = strF2 Then GoTo Notify ActiveCell.Select Else: MsgBox "Not Found" Exit Sub End If Set c = .FindNext(c) If Not c Is Nothing And c.Address < strAdd Then Do If c(1, 2).Value = strF2 Then GoTo Notify Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < strAdd End If End With Notify: MsgBox """" & strF1 & """ is next to """ & _ strF2 & """ in cells " & c.Resize(1, 2).Address Selection.EntireRow.Select End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
select row
is there a way of selecting cells a to s instead of the entire row as i want
to copy the info. "Die_Another_Day" wrote: Change this: Selection.EntireRow.Select To this Rows(c.Row).Select Charles enyaw wrote: This is my current code. It allows me to search two columns and returns where the values are via a message box. I want to be able to select the row the values are in. Can anyone help? Private Sub CommandButton1_Click() Dim c As range Dim strF1 As String Dim strF2 As String Dim strAdd As String If UserForm3.TextBox5.Text = "" Then MsgBox "Please enter Part Number" UserForm3.TextBox5.SetFocus Exit Sub End If If UserForm3.TextBox6.Text = "" Then MsgBox "Please enter Sequence Number" UserForm3.TextBox6.SetFocus Exit Sub End If strF1 = UserForm3.TextBox5.Text strF2 = UserForm3.TextBox6.Text 'Assumes that Part numbers are in column B With ActiveSheet.range("B:B") Set c = .Find(strF1, LookIn:=xlValues, lookAt:=xlWhole) If Not c Is Nothing Then strAdd = c.Address If c(1, 2).Value = strF2 Then GoTo Notify ActiveCell.Select Else: MsgBox "Not Found" Exit Sub End If Set c = .FindNext(c) If Not c Is Nothing And c.Address < strAdd Then Do If c(1, 2).Value = strF2 Then GoTo Notify Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < strAdd End If End With Notify: MsgBox """" & strF1 & """ is next to """ & _ strF2 & """ in cells " & c.Resize(1, 2).Address Selection.EntireRow.Select End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
select row
Range("A" & C.Row & ":S" & C.Row).Select
Charles enyaw wrote: is there a way of selecting cells a to s instead of the entire row as i want to copy the info. "Die_Another_Day" wrote: Change this: Selection.EntireRow.Select To this Rows(c.Row).Select Charles enyaw wrote: This is my current code. It allows me to search two columns and returns where the values are via a message box. I want to be able to select the row the values are in. Can anyone help? Private Sub CommandButton1_Click() Dim c As range Dim strF1 As String Dim strF2 As String Dim strAdd As String If UserForm3.TextBox5.Text = "" Then MsgBox "Please enter Part Number" UserForm3.TextBox5.SetFocus Exit Sub End If If UserForm3.TextBox6.Text = "" Then MsgBox "Please enter Sequence Number" UserForm3.TextBox6.SetFocus Exit Sub End If strF1 = UserForm3.TextBox5.Text strF2 = UserForm3.TextBox6.Text 'Assumes that Part numbers are in column B With ActiveSheet.range("B:B") Set c = .Find(strF1, LookIn:=xlValues, lookAt:=xlWhole) If Not c Is Nothing Then strAdd = c.Address If c(1, 2).Value = strF2 Then GoTo Notify ActiveCell.Select Else: MsgBox "Not Found" Exit Sub End If Set c = .FindNext(c) If Not c Is Nothing And c.Address < strAdd Then Do If c(1, 2).Value = strF2 Then GoTo Notify Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < strAdd End If End With Notify: MsgBox """" & strF1 & """ is next to """ & _ strF2 & """ in cells " & c.Resize(1, 2).Address Selection.EntireRow.Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA: Column Select then Data Select then return to cell A1 | Excel Discussion (Misc queries) | |||
Macro to select cells without a certain value and select a menu it | Excel Worksheet Functions | |||
Using formulas to select cells (Ex: Select every nth cell in a col | Excel Discussion (Misc queries) | |||
In Excel 2000, How do you select the whole of a worksheet (Select. | Excel Discussion (Misc queries) | |||
Select other workbook to select data in a macro. | Excel Programming |