+ Reply to Thread
Results 1 to 2 of 2

ModifyVBA To Find Next Blank Cell in Column A instead Of Next Blank Row

  1. #1
    jjward101
    Guest

    ModifyVBA To Find Next Blank Cell in Column A instead Of Next Blank Row

    Good Morning!

    Can anyone help me to understand what I would need to do to modify the below code so that It is looking for the next empty cell in Column A instead of the next Empty row? Because I have formulas in every row other columns, the next entry is going to the very end of the sheet instead of the next blank row. This is upon hitting a submit button in a userform. THank you.

    Code:

    PHP Code: 

    Private Sub ListBox3_Click()

    End Sub

    Private Sub CommandButton1_Click()

    Dim WS_Data As Worksheet
    Dim LastRow 
    As Long
    Dim NextRow 
    As Long

    Set WS_Data 
    Worksheets("Customers")
    'find last row
    LastRow = WS_Data.Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
    NextRow = LastRow + 1

    '
    Enter data to "Data" sheet
    WS_Data
    .Range("A" NextRow) = TextBox1.Value
    WS_Data
    .Range("B" NextRow) = TextBox2.Value
    WS_Data
    .Range("C" NextRow) = TextBox3.Value
    WS_Data
    .Range("D" NextRow) = TextBox4.Value
    WS_Data
    .Range("E" NextRow) = TextBox5.Value
    WS_Data
    .Range("F" NextRow) = ComboBox1.Value
    WS_Data
    .Range("G" NextRow) = ComboBox2.Value
    WS_Data
    .Range("H" NextRow) = ComboBox3.Value
    WS_Data
    .Range("I" NextRow) = TextBox6.Value
    WS_Data
    .Range("J" NextRow) = TextBox7.Value
    WS_Data
    .Range("K" NextRow) = TextBox8.Value
    WS_Data
    .Range("L" NextRow) = ComboBox4.Value
    WS_Data
    .Range("M" NextRow) = ComboBox5.Value

    'Clear the textboxes
    TextBox1.Value = ""
    TextBox2.Value = ""
    TextBox3.Value = ""
    TextBox4.Value = ""
    TextBox5.Value = ""
    TextBox6.Value = ""
    TextBox7.Value = ""
    TextBox8.Value = ""
    ComboBox1.Value = ""
    ComboBox2.Value = ""
    ComboBox3.Value = ""
    ComboBox4.Value = ""
    ComboBox5.Value = ""

    '
    Save workbook
    ActiveWorkbook
    .Save
    UserForm1
    .Hide

    End Sub

    Private Sub CommandButton2_Click()
    UserForm1.Hide
    End Sub
    Private Sub UserForm_Initialize()

    With ComboBox1
        
    .AddItem "Atlantic"
        
    .AddItem "Berks"
        
    .AddItem "Cape May"
        
    .AddItem "Camden"
        
    .AddItem "Chester"
        
    .AddItem "Cecil"
        
    .AddItem "Cumberland"
        
    .AddItem "Delaware"
        
    .AddItem "Philadelphia"
        
    .AddItem "Lehigh"
        
    .AddItem "Monroe"
        
    .AddItem "Montgomery"
        
    .AddItem "Kent De"
        
    .AddItem "Gloucester"
        
    .AddItem "Lehigh"
        
    .AddItem "Newcastle De"
        
    .AddItem "Salem"
        
    With ComboBox2
        
    .AddItem "Government"
        
    .AddItem "K-12 Education"
        
    .AddItem "Banking/Finance"
        
    .AddItem "Higher Ed."
        
    .AddItem "Healthcare"
        
    .AddItem "Manufacturing"
        
    .AddItem "Hospitality"
        
    .AddItem "Religious"
        
    .AddItem "Retail"
        
    .AddItem "Real Estate"
        
    .AddItem "Entertainment"
        
    .AddItem "Transportation"
        
    .AddItem "Utility"
        
    With ComboBox3
        
    .AddItem "Target"
        
    .AddItem "Managed"
        
    .AddItem "Key"
        
    .AddItem "New"
        
    With ComboBox4
        
    .AddItem "Fire Alarm"
        
    .AddItem "Sprinkler"
        
    .AddItem "Suppression"
        
    .AddItem "Extinguishers"
        
    .AddItem "Intrusion Alarm"
        
    .AddItem "Access Control"
        
    .AddItem "CCTV"
        
    .AddItem "Audio-Video"
        
    .AddItem "Healthcare Communications"
        
    .AddItem "Visitor Management"
        
    .AddItem "Education Electronics"
        
    With ComboBox5
        
    .AddItem "Fire Alarm"
        
    .AddItem "Sprinkler"
        
    .AddItem "Suppression"
        
    .AddItem "Extinguishers"
        
    .AddItem "Intrusion Alarm"
        
    .AddItem "Access Control"
        
    .AddItem "CCTV"
        
    .AddItem "Audio-Video"
        
    .AddItem "Healthcare Communications"
        
    .AddItem "Visitor Management"
        
    .AddItem "Education Electronics"
      
        
    End With
        End With
        End With
        End With
        End With
        
    End Sub 

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,944

    Re: ModifyVBA To Find Next Blank Cell in Column A instead Of Next Blank Row

    Try changing

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find Next Blank Cell In Column A
    By jjward101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-08-2023, 05:28 PM
  2. [SOLVED] Find first and last non-blank (non-empty) cell, and First blank cell in a row or column
    By niksirat2030 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-31-2022, 03:37 AM
  3. Replies: 6
    Last Post: 03-01-2018, 12:16 PM
  4. [SOLVED] VBA Find last row and column that contain data and delete all blank rows and blank columns
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-03-2012, 01:07 PM
  5. [SOLVED] Find first non-blank cell after a group of blanks copy offset cells, find next blank, loop
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2012, 06:11 AM
  6. Find a blank cell and calculate the average of all cells above till the next blank
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 11:51 AM
  7. Find first blank cell in column if rightmost cell is non blank
    By Mothman in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-19-2010, 02:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1