Find first empty cell in selected area depending on data input of 2 textbox

apoliboli

New Member
Joined
Jun 23, 2017
Messages
7
Hi. How can i find the first empty cell in a row
if textboxA is > 500 and textboxB = "hello" go to (first empty cell in )C2-C6
if textboxA > 500 and textboxB = "goodbye" got to (first empty cell in )C7-C11
if textboxA < 499 and textboxB = "hello" go to "first empty call in ) D2-D6
if textboxA < 499 and textboxB ="goodbye" got to (first empty cell in )D7-D11

thx
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
See if you can use this

Code:
Sub t()
With ActiveSheet
If .textboxA.Value > 500 And .textboxB.Text = "hello" And Application.CountA(.Range("C2:C6")) < 5 Then
    If .Cells(2, 3) <> "" Then
        .Cells(1, 3).End(xlDown)(2).Select
    Else
        .Cells(2, 3).Select
    End If
ElseIf .textboxA.Value > 500 And .textboxB.Text = "goodbye" And Application.CountA(.Range("C7:C11")) < 5 Then
    If .Cells(7, 3) <> "" Then
        .Cells(6, 3).End(xlDown)(2).Select
    Else
        .Cells(7, 3).Select
    End If
 ElseIf .textboxA.Value < 499 And .textboxB.Text = "hello" And Application.CountA(.Range("D2:D6")) < 5 Then
    If .Cells(2, 4) <> "" Then
        .Cells(1, 4).End(xlDown)(2).Select
    Else
        .Cells(2, 4).Select
    End If
 ElseIf .textboxA.Value < 499 And .textboxB.Text = "goodbye" And Application.CountA(.Range("D7:D11")) > 5 Then
    If .Cells(7, 4) <> "" Then
        .Cells(6, 4).End(xlDown)(2).Select
    Else
        .Cells(7, 4).Select
    End If
End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,535
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top