Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8861631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:32:04+00:00 2026-06-14T15:32:04+00:00

I am new to VBA in Excel, and I have a basic userform which

  • 0

I am new to VBA in Excel, and I have a basic userform which is to place the data into the sheet. the data from the form is to enter in cell B13 through to G13, then every other entry after should be done on the next row down e.g. B14-G14.

I have this code already however it isnt entering the data into the correct cell and is repeatedly entering it on the same row…

     Private Sub CommandButton1_Click()

Dim lngWriteRow As Long

Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

lngWriteRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

If lngWriteRow < 13 Then lngWriteRow = 13

    ws.Range("B" & lngWriteRow) = TextBox1.Value
    ws.Range("C" & lngWriteRow) = TextBox2.Value
    ws.Range("D" & lngWriteRow) = TextBox3.Value
    ws.Range("E" & lngWriteRow) = ComboBox1.Value
    ws.Range("F" & lngWriteRow) = TextBox4.Value
    ws.Range("G" & lngWriteRow) = ComboBox2.Value

End Sub

How would i achieve this? (There is already data on the rows below)

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:32:05+00:00Added an answer on June 14, 2026 at 3:32 pm

    This line here is wrong:

    lngWriteRow = ws.Cells(Rows.Count, 12) _
    .End(xlUp).Offset(1, 0).Row
    

    Because you are referring to column 12, which you do not alter – hence the row stays the same.

    Use this instead

    lngWriteRow = ws.Cells(Rows.Count, 2) _
    .End(xlUp).Offset(1, 0).Row
    

    Edit:

    If you want an initial offset, to start the data-input @ row 13, use this:

    lngWriteRow = ws.Cells(Rows.Count, 2) _
    .End(xlUp).Offset(1, 0).Row
    
    if lngWriteRow < 13 then lngWriteRow = 13
    

    You cannot use Offset(12,0), because you would use it everytime!

    Edit

    Just to be crystal clear, this here works on an empty sheet, when pasting the code as a worksheet-macro and hitting F5 multiple times. So, unless there is explained, what this does wrong, I consider the question solved.

    Private Sub Test()
    
    Dim lngWriteRow As Long
    
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")
    
    lngWriteRow = ws.Cells(Rows.Count, 2) _
    .End(xlUp).Offset(1, 0).Row
    
    If lngWriteRow < 13 Then lngWriteRow = 13
    
        ws.Range("B" & lngWriteRow) = "test"
        ws.Range("C" & lngWriteRow) = "test"
        ws.Range("D" & lngWriteRow) = "test"
        ws.Range("E" & lngWriteRow) = "test"
        ws.Range("F" & lngWriteRow) = "test"
        ws.Range("G" & lngWriteRow) = "test"
    
    End Sub
    

    Edit

    After some mailing, here is the solution to this riddle: it was not stated, that there are filled cells beneath those, which shall be entered.

    So for col-B it was more like

    title-row
    row13
    row..
    row..
    row63
    space
    other stuff
    

    basically the suggested corrections worked – but they looked for the last filled cell in column B on the whole sheet, which was the problem.

    Here is the solution to that:

    lngWriteRow = ws.Cells(ws.Range("B12:B63")Rows.Count, 2) _
    .End(xlUp).Offset(1, 0).Row
    

    And to give you some explanaition on the way:

    You can’t use (Rows.Count,1) instead of (Rows.Count,2), because you are adding Data in the columns B-G, which is 2-7. You have to use 2-7 because of the way, you are looking for the last row. If you use 1, you’re looking for the last value in column A, which does not change, when you are trying to add new data.

    You can’t use Offset(12,0), because this would create an offset everytime you insert data – so you would end up with rows 12 rows apart.

    And finally, you can’t use Rows.Count, because this is 65536 or so, and you have data beneath the data you are adding. End(xlUp) will lookup from too far down, and stop at the last cell of column B, which has data in it – but this won’t be B13, unless there is no data in B14-B65536.

    Hope this helps to understand the dynamics here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel form which reads data from each row of an 80-row
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have the following code in my Excel VBA that copies data from a
I have an excel sheet that I am wanting to extract data from and
I have a excel file which contains 5 sheets in it. The 1st sheet
My requirement is I have a Excel which contains some data. I would like
I have created a COM library in c# which I am consuming from VBA
I am fairly new to Excel VBA and have been trying to look for
I am new to Active Directory. I have a VBA Excel Add-In that should
I have data in an excel sheet in the following format: ItemCode DeliveryDate 5456987

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.