Manage If Then Statement

Guard913

Board Regular
Joined
Apr 10, 2016
Messages
144
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
This is My Code:
(Submit_Sub1 - Finds next empty row and fills it)
(Account#_Update - Updates the row that matches Cell Info)
What I am looking for:
Works fine if I only have "If Sheets("Account List").Range("A2") = "" Then Call Submit_Sub1" but what I am looking for it to do, is if A2 has an item it checks A3 if A3 is blank it will Fill it and then exit this section and move to code
"If Call_Form.TextBox8.Value = Sheets("Account List").Range("A2") Then Call Account1_Update" and check info against that. Eventually reaching bottom and Ending.

The idea is everytime I click on button to switch accounts it will update the correct line with what ever info is currently in my lists, and if no line has been made it will make a new line, update it then allow me to select an account.

Right now on my form I have a Submit Button and an Update button... Before I can click combobox which has a dropbuttonclick code which pulls the list. I just want the dropbuttoncode to handle all of it so I don't even have to think about it.


VBA Code:
Sub Full_Update()
If Sheets("Account List").Range("A2") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A3") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A4") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A5") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A6") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A7") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A8") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A9") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A10") = "" Then Call Submit_Sub1
If Sheets("Account List").Range("A11") = "" Then Call Submit_Sub1
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A2") Then Call Account1_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A3") Then Call Account2_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A4") Then Call Account3_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A5") Then Call Account4_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A6") Then Call Account5_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A7") Then Call Account6_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A8") Then Call Account7_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A9") Then Call Account8_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A10") Then Call Account9_Update
If Call_Form.TextBox8.Value = Sheets("Account List").Range("A11") Then Call Account10_Update

End Sub
 
VBA Code:
Sub Full_Update()
    Dim wb As Workbook
    Dim sh As Worksheet
    Dim rg As Range
    
    Set wb = ActiveWorkbook
    Set sh = wb.Sheets("Account List")
    Set rg = sh.Range("A2:A11")
    
    For Each cell In rg
        If cell = vbNullString Then
            Call Submit_Sub1
            Exit For
        ElseIf cell = Call_Form.TextBox8.Value Then
            xindex = Call_Form.ComboBox200.ListIndex + 1
            Application.Run "Account" & xindex & "_Update"
            Call_Form.ComboBox200.Value = ""
            Exit For
        End If
    
    Next cell

End Sub

Suggested by Extreminador via Discord!
And it works!!
 
Upvote 0
Solution

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

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