+ Reply to Thread
Results 1 to 22 of 22

Have textbox.value populate cells in a certain row and column

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Have textbox.value populate cells in a certain row and column

    I have a formula that doesn't quite seem to work. First I tried to make a formula to match the text in row 4 and then input the text from another box in a row below that. Does it matter if it is merged?

    here is the code so far:

    Private Sub SubmitButton_Click()
    Dim emptyRow As Long
    Dim emptyCol As Long
    Dim Res As Variant
        With Sheet2
            Res = Application.Match(Roomnum.Value, .Rows(4), 0)
                If Not IsError(Res) Then
                    emptyRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
                Else
                    emptyRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
                    .Range("C" & emptyRow).Value = Credittxt.Value
                End If
        End With
    End Sub
    Last edited by Templemind; 09-13-2014 at 04:12 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Have textbox.value populate cells in a certain row and column

    Hi, Templemind,

    avoid merged cells not if possible but at all!

    Why are both If-Statements referring to Column A insteasd of the column you picked up in res? Why write to Column C?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: Have textbox.value populate cells in a certain row and column

    I will take out merged cells. However, doing that did not change anything.

    Woops I didn't see that. To tell you the truth I tried to copy the formula from somewhere else and change it to look in row 4 for the Roomnum.Value, but it does not do that. Perhaps I am confused to what the numbers are for.

  4. #4
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: Have textbox.value populate cells in a certain row and column

    I can get the text to enter in the correct column now, but I cannot get the match to work. Is there something wrong with it?

    Here is the code now.
    Private Sub SubmitButton_Click()
    Dim emptyRow As Long
    Dim emptyCol As Long
    Dim Res As Variant
        With Sheet2
            Res = Application.Match(Roomnum.Value, .Rows(4), 0)
                If Not IsError(Res) Then
                    emptyRow = .Cells(Rows.Count, 5).End(xlUp).Row
                Else
                    emptyRow = .Cells(Rows.Count, 5).End(xlUp).Row + 1
                    .Range("C" & emptyRow).Value = Credittxt.Value
                End If
        End With
        Unload Addform
    End Sub

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Have textbox.value populate cells in a certain row and column

    Hi, Templemind,

    Res ia a Variable while number 5 is a constant, itīs simple as that. I would suggest not to work with a Textbox to let the user type items (I prefer a Listbox or Combobox where the items are listed or may be added if needed).

    Private Sub SubmitButton_Click()
    Dim emptyRow As Long
    Dim Res As Variant
    With Sheet2
      Res = Application.Match(Roomnum.Value, .Rows(4), 0)
      If Not IsError(Res) Then
          emptyRow = .Cells(Rows.Count, Res).End(xlUp).Offset(1, 0).Row
          .Cells(emptyRow, Res).Value = Credittxt.Value
      End If
    End With
    End Sub
    I donīt see your workbook so it may be a typo or the searched value may just be part of the string in the cell or there may be formulas...

    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: Have textbox.value populate cells in a certain row and column

    The reason why I have it as text and not as a listbox is because there are 39 entries and I think that is a bit long.

    The match does not seem to work still. I have attached the workbook so you can see what I am working with. It is not too difficult, but I am just not getting it. I want it to find a match in row 4 from A to CA with some of the rows being blank.
    Attached Files Attached Files

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Have textbox.value populate cells in a certain row and column

    Hi, Templemind,

    you are looking for text in a row where just numbers are listed.

    Private Sub SubmitButton_Click()
    Dim emptyRow As Long
    Dim Res As Variant
    With Sheet2
      Res = Application.Match(CLng(Roomnum.Value), .Rows(4), 0)
      If Not IsError(Res) Then
          .Cells(Rows.Count, Res).End(xlUp).Offset(1, 0).Value = Credittxt.Value
      End If
    End With
    End Sub
    You could use your variable to make sure that the entries start from a certsain row on, and maybe have to adjust the column to which to write (this is the first of the two merged cells).

    Ciao,
    Holger

+ 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. [SOLVED] Have a textbox value populate a certain range of cells only
    By Templemind in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2014, 08:02 AM
  2. Populate TextBox from Module prior to opening TextBox
    By Dabbler39 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-05-2013, 05:50 PM
  3. [SOLVED] Auto populate cells in one column based if cells in next column are populated
    By diablo86 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-22-2013, 06:29 AM
  4. Populate a column based on input from a textbox
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2012, 03:39 PM
  5. [SOLVED] UserForm TextBox and ComboBox selections populate SPECIFIC spreadsheet cells
    By ZIXILPLIX in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-23-2010, 02:45 AM

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