Consulting

Results 1 to 5 of 5

Thread: How to display values in excel sheet from vba Form.

  1. #1

    How to display values in excel sheet from vba Form.

    Hi All,
    I want Fetch values from vba form based on the input values given in the textbox.
    Eg : Say if i enter a value 1 in textbox and click on OK button, this textbox value should be displayed in excel "sheet1" - cell (A1).
    I could get this by the below code for a single cell(A1):
    Range("A1").Value = TextBox1.Text

    output
    ------
    1

    If i again enter the value in the textbox , it should display in the next cell i.e (A2).

    output
    ------
    1
    2

    Could anyone please help me on the above??

  2. #2
    VBAX Expert
    Joined
    Aug 2004
    Posts
    810
    Location
    Try this
    [vba]
    cells(textbox1.text, 1) = textbox1.text
    [/vba]

  3. #3
    Quote Originally Posted by JKwan
    Try this
    [vba]
    cells(textbox1.text, 1) = textbox1.text
    [/vba]

    I think i have to provide the value exactly 1,2 and then followed by 3 etc..how abt the text value or any large number??

    Eg : 1
    Sample
    12657

    Can you help on this??

  4. #4
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location
    Try this
    Dim last_row  As Long
    last_row = Cells(Rows.Count, 1).End(xlUp).Row
    If last_row = 1 And Cells(last_row, 1).Value = "" Then
        last_row = 0
    End If
    last_row = last_row + 1
    Cells(last_row, 1).Value = textbox1.Text

  5. #5
    Quote Originally Posted by mohanvijay
    Try this
    Dim last_row  As Long
    last_row = Cells(Rows.Count, 1).End(xlUp).Row
    If last_row = 1 And Cells(last_row, 1).Value = "" Then
        last_row = 0
    End If
    last_row = last_row + 1
    Cells(last_row, 1).Value = textbox1.Text
    Mohan,
    Thank you so much !!

Posting Permissions

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