ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do i write an offset code ? (https://www.excelbanter.com/excel-programming/380477-re-how-do-i-write-offset-code.html)

Corey

How do i write an offset code ?
 
JMB,

This is what i have now, but to date i still get no other value in the sheet
Previewed except for the Combobox1.value in cell("O4") ???

Did i miss something you advised here?



Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
With ActiveWorkbook.workSheets("Inspections")
..Select
Range("O4").Value = ComboBox1.Value ' This works Great
UserForm3.Hide

Dim rngFound As Range
On Error Resume Next
With workSheets("InspectionData").Range("A:A")
Set rngFound = .Find(what:=Me.ComboBox1.Value, after:=.Range("A1"),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
End With
On Error GoTo 0
If Not rngFound Is Nothing Then
workSheets("Inspections").Range("E2").Value = rngFound.Offset(-1, 2).Value
' <========== There is a value in "InspectionData".Range"C1" BUT this does
not display in the Sheet"Inspections".Range"E2" ???
End If
ActiveWindow.SelectedSheets.PrintPreview ' Preview worksheet to either
Print of simply View
Range("O4,E2").ClearContents ' Clears all data that was brought in from
sheet "InspectionData"
Sheets("Main").Select ' Takes the user back to the Main Page
Range("A1").Select
Application.ScreenUpdating = True
End With
Unload Me
End Sub


Corey....



JMB

How do i write an offset code ?
 
First, I would test the data to make sure they are the same. It appears the
combobox value is in O4 and the value you are trying to match it to is in A1,
so in an empty cell somewhere, enter:

=Inspections!O4=InspectionData!A1

If it's false, the two values are not the same.

If that fails, is it possible to email the book to me?

jeffblakley@
hotmail.com


"Corey" wrote:

JMB,

This is what i have now, but to date i still get no other value in the sheet
Previewed except for the Combobox1.value in cell("O4") ???

Did i miss something you advised here?



Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
With ActiveWorkbook.workSheets("Inspections")
..Select
Range("O4").Value = ComboBox1.Value ' This works Great
UserForm3.Hide

Dim rngFound As Range
On Error Resume Next
With workSheets("InspectionData").Range("A:A")
Set rngFound = .Find(what:=Me.ComboBox1.Value, after:=.Range("A1"),
LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
End With
On Error GoTo 0
If Not rngFound Is Nothing Then
workSheets("Inspections").Range("E2").Value = rngFound.Offset(-1, 2).Value
' <========== There is a value in "InspectionData".Range"C1" BUT this does
not display in the Sheet"Inspections".Range"E2" ???
End If
ActiveWindow.SelectedSheets.PrintPreview ' Preview worksheet to either
Print of simply View
Range("O4,E2").ClearContents ' Clears all data that was brought in from
sheet "InspectionData"
Sheets("Main").Select ' Takes the user back to the Main Page
Range("A1").Select
Application.ScreenUpdating = True
End With
Unload Me
End Sub


Corey....





All times are GMT +1. The time now is 11:23 AM.

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