dizzydunham
New Member
- Joined
- Mar 22, 2014
- Messages
- 30
I have entered the code below from searching the web, all works spot on when I put week ending in the column and search text box, but if I put dates in the column instead and a date in the search textbox then I get a error highlighting ABnum=Textbox1.value
As a learner in this world, its probably going to blinding obvious to most of you, but I cant see it. Ive tried a few things like dim double to integer, but got no where.
Any help gratefully received.
Sub CommandButton1_Click()
' To write edited info of userform2 to Sheets("Succession Database")
Dim LastRow As Long
Dim ABnum As Double
Dim ABrng As Range
Dim WriteRow As Long
' Make sure we're on the right sheet dc2a1
Sheets("DC2A1").Select
With ActiveSheet
' Get the last row used so can set up the search range
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
' Set the range to search for the AB number
Set ABrng = .Range("A1:A" & LastRow)
' Get the AB number from what is selected on userform2
ABnum = TextBox1.Value
' Get the row of sheet for this AB number
WriteRow = Application.Match(ABnum, ABrng, 0)
' Make this AB number the active cell
Cells(WriteRow, 1).Select
' Write in all the editable stuff, don't bother with the non-editable things
With ActiveCell
.Offset(0, 18).Value = ComboBox2.Value
.Offset(0, 15).Value = ComboBox1.Value
.Offset(0, 16).Value = TextBox2.Value
.Offset(0, 17).Value = Now()
'etc.
'etc.
End With
End With
'next sheet dc2a2
As a learner in this world, its probably going to blinding obvious to most of you, but I cant see it. Ive tried a few things like dim double to integer, but got no where.
Any help gratefully received.
Sub CommandButton1_Click()
' To write edited info of userform2 to Sheets("Succession Database")
Dim LastRow As Long
Dim ABnum As Double
Dim ABrng As Range
Dim WriteRow As Long
' Make sure we're on the right sheet dc2a1
Sheets("DC2A1").Select
With ActiveSheet
' Get the last row used so can set up the search range
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
' Set the range to search for the AB number
Set ABrng = .Range("A1:A" & LastRow)
' Get the AB number from what is selected on userform2
ABnum = TextBox1.Value
' Get the row of sheet for this AB number
WriteRow = Application.Match(ABnum, ABrng, 0)
' Make this AB number the active cell
Cells(WriteRow, 1).Select
' Write in all the editable stuff, don't bother with the non-editable things
With ActiveCell
.Offset(0, 18).Value = ComboBox2.Value
.Offset(0, 15).Value = ComboBox1.Value
.Offset(0, 16).Value = TextBox2.Value
.Offset(0, 17).Value = Now()
'etc.
'etc.
End With
End With
'next sheet dc2a2