PDA

View Full Version : How to display values in excel sheet from vba Form.



riyasen
06-23-2011, 08:26 PM
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??

JKwan
06-23-2011, 09:20 PM
Try this

cells(textbox1.text, 1) = textbox1.text

riyasen
06-23-2011, 10:56 PM
Try this

cells(textbox1.text, 1) = textbox1.text



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??

mohanvijay
06-24-2011, 01:31 AM
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

riyasen
06-26-2011, 06:44 PM
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 :) !!