ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   next cell (https://www.excelbanter.com/excel-programming/276813-re-next-cell.html)

Dave Peterson[_3_]

next cell
 
Maybe you can do something with this:

Option Explicit
Sub testme()

Dim FCell As Range
Dim destCell As Range

With ActiveSheet.Columns(1)
Set FCell = .Find(what:="31", after:=.Cells(1), _
LookIn:=xlValues, lookat:=xlWhole, _
searchdirection:=xlPrevious, _
MatchCase:=False, searchorder:=xlByRows)
End With

If FCell Is Nothing Then
MsgBox "not found"
Else
If IsEmpty(FCell.Offset(1, 0)) Then
Set destCell = FCell.Offset(1, 0)
Else
Set destCell = FCell.End(xlDown).Offset(1, 0)
End If

'do what you want to destcell
destCell.Value = "whatever"
End If

End Sub


David W wrote:

Got a little problem, got this one pieced together with 1 glitch
It does what it says, but I need it to go to the last number in that
search(the way the sheet is laid out is when there is a entry, it puts the
index number from the combobox each time, anotherwords (lets use 31 as the
combobox's selected value) if you have got 12 entries, there will be 12
"31's" "in column A", I need to go to the next empty cell after the last
"31" and insert the values from the boxes being used in this form.
Keep in mind that this maybe in the middle of the sheet between existing
records where there will be other numbers in the same column but, not the
same number(the column start from the smallest to the biggest top to bottom

Private Sub CommandButton2_Click()
Dim Fcell As Range
Set Fcell = Columns(1).Find(ComboBox1, lookat:=xlWhole)
If Fcell = ComboBox1.value Then
Sheets("kenjan").Unprotect ("?")
Fcell.Select
ActiveCell.Next.Select
ActiveCell.Offset(1, 0) = ComboBox1.value
ActiveCell.Offset(1, 3) = TextBox1.value
ActiveCell.Offset(1, 5) = TextBox1.value
ActiveCell.Offset(1, 7) = TextBox1.value
ActiveCell.Offset(1, 9) = Val(Me.TextBox3.value) - Val(Me.TextBox2.value)
TextBox1.value = ""
TextBox2.value = ""
TextBox3.value = ""
End If
End Sub


--

Dave Peterson


David W[_3_]

next cell
 
ended up doing this

for this to work right there has to be 2 of the numbers in column 1 or it
will not work (they can be hidden) if not it will go to the next report

thanks for trying

Private Sub CommandButton2_Click()
Dim Fcell As Range
Set Fcell = Columns(1).Find(ComboBox1, lookat:=xlWhole)
If Fcell = ComboBox1.value Then
Sheets("kenjan").Unprotect ("?")
Fcell.Select
Selection.End(xlDown).Select
ActiveCell.Offset(1) = ComboBox1.value
ActiveCell.Offset(1, 2) = TextBox1.value
ActiveCell.Offset(1, 4) = TextBox2.value
ActiveCell.Offset(1, 6) = TextBox3.value
ActiveCell.Offset(1, 8) = Val(Me.TextBox3.value) - Val(Me.TextBox2.value)
TextBox1.value = ""
TextBox2.value = ""
TextBox3.value = ""
Range("A1").Show
End If
End Sub




All times are GMT +1. The time now is 02:56 AM.

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