ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Value NOT being input (https://www.excelbanter.com/excel-programming/383272-value-not-being-input.html)

Corey

Value NOT being input
 
The below code places valuies from the Sheet-"Data" into the Sheet-"Job card",
BUT, the Highlighted LINE value DOES NOT apear, WHY ??
Removing the 'On Error Resume Next' i get a Object Variable not set error.


Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
UserForm2.Hide
With ActiveWorkbook.Worksheets("Job Card")
..Select
Dim rngFound As Range
' On Error Resume Next
With Worksheets("Data").Range("A:A")
Set rngFound = .Find(What:=UserForm2.ListBox1.Value, After:=.Range("A1"), LookIn:=xlValues,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, Matchbyte:=False)
Range("B2").Value = ListBox1.Value
Range("B6").Value = rngFound.Offset(0, 4).Value ' <===== Error here !!!
End With
' Preview worksheet to either Print of simply View
ActiveWindow.SelectedSheets.PrintPreview
' Clears all data that was brought in from sheet "InspectionData"
Dim c As Range
For Each c In Sheets("Job Card").UsedRange
If c.Locked = False Then
c.ClearContents
End If
Next
Sheets("NavigationPage").Activate
On Error GoTo 0
End With
Unload Me
Application.ScreenUpdating = True
End Sub

Help ??

Corey....



Corey

Value NOT being input
 
Never mind sussed it out.
Had a Custom value infront of the Numerical value, therefore the xlWhole did not find it.

"Corey" wrote in message ...
The below code places valuies from the Sheet-"Data" into the Sheet-"Job card",
BUT, the Highlighted LINE value DOES NOT apear, WHY ??
Removing the 'On Error Resume Next' i get a Object Variable not set error.


Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
UserForm2.Hide
With ActiveWorkbook.Worksheets("Job Card")
..Select
Dim rngFound As Range
' On Error Resume Next
With Worksheets("Data").Range("A:A")
Set rngFound = .Find(What:=UserForm2.ListBox1.Value, After:=.Range("A1"), LookIn:=xlValues,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, Matchbyte:=False)
Range("B2").Value = ListBox1.Value
Range("B6").Value = rngFound.Offset(0, 4).Value ' <===== Error here !!!
End With
' Preview worksheet to either Print of simply View
ActiveWindow.SelectedSheets.PrintPreview
' Clears all data that was brought in from sheet "InspectionData"
Dim c As Range
For Each c In Sheets("Job Card").UsedRange
If c.Locked = False Then
c.ClearContents
End If
Next
Sheets("NavigationPage").Activate
On Error GoTo 0
End With
Unload Me
Application.ScreenUpdating = True
End Sub

Help ??

Corey....




Corey

Value NOT being input
 
Now it is NOT working ???
"Corey" wrote in message ...
The below code places valuies from the Sheet-"Data" into the Sheet-"Job card",
BUT, the Highlighted LINE value DOES NOT apear, WHY ??
Removing the 'On Error Resume Next' i get a Object Variable not set error.


Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
UserForm2.Hide
With ActiveWorkbook.Worksheets("Job Card")
..Select
Dim rngFound As Range
' On Error Resume Next
With Worksheets("Data").Range("A:A")
Set rngFound = .Find(What:=UserForm2.ListBox1.Value, After:=.Range("A1"), LookIn:=xlValues,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, Matchbyte:=False)
Range("B2").Value = ListBox1.Value
Range("B6").Value = rngFound.Offset(0, 4).Value ' <===== Error here !!!
End With
' Preview worksheet to either Print of simply View
ActiveWindow.SelectedSheets.PrintPreview
' Clears all data that was brought in from sheet "InspectionData"
Dim c As Range
For Each c In Sheets("Job Card").UsedRange
If c.Locked = False Then
c.ClearContents
End If
Next
Sheets("NavigationPage").Activate
On Error GoTo 0
End With
Unload Me
Application.ScreenUpdating = True
End Sub

Help ??

Corey....




Dave Peterson

Value NOT being input
 
after you do the .find, you'll want to test to see if you actually found the
value

set rngfound = .find.....

if rngfound is nothing then
'what should happen, msgbox, exit sub, beep???
else
'do the real work
end if



Corey wrote:

Now it is NOT working ???
"Corey" wrote in message ...
The below code places valuies from the Sheet-"Data" into the Sheet-"Job card",
BUT, the Highlighted LINE value DOES NOT apear, WHY ??
Removing the 'On Error Resume Next' i get a Object Variable not set error.

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
UserForm2.Hide
With ActiveWorkbook.Worksheets("Job Card")
.Select
Dim rngFound As Range
' On Error Resume Next
With Worksheets("Data").Range("A:A")
Set rngFound = .Find(What:=UserForm2.ListBox1.Value, After:=.Range("A1"), LookIn:=xlValues,
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, Matchbyte:=False)
Range("B2").Value = ListBox1.Value
Range("B6").Value = rngFound.Offset(0, 4).Value ' <===== Error here !!!
End With
' Preview worksheet to either Print of simply View
ActiveWindow.SelectedSheets.PrintPreview
' Clears all data that was brought in from sheet "InspectionData"
Dim c As Range
For Each c In Sheets("Job Card").UsedRange
If c.Locked = False Then
c.ClearContents
End If
Next
Sheets("NavigationPage").Activate
On Error GoTo 0
End With
Unload Me
Application.ScreenUpdating = True
End Sub

Help ??

Corey....


--

Dave Peterson


All times are GMT +1. The time now is 02:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com