Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert data into a worksheet 1

Status
Not open for further replies.

PartyGoerGeek

Programmer
Oct 19, 2010
4
ID
My Name is Paul, I am a new guy in Excel. I need some advise in how to insert data into a worksheet from VBA form, example: in my form I have a text box, I want the value of the text box inserted into a worksheet at a spesific column. or if you have any free e-book or free refrence. Please Let me know. Thanx.


Regards,


PartyGoerGeek.
 



Hi,
Assuming that YourColumn has a heading in row 1...
Code:
With YourSheetObject
   lRow = Application.Counta(Columns(YourColumn)) + 1 
   .cells(lRow, YourColumn).value = YourTextBoxObject.Text
End with


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Assuming you're writing a macro within a workbook and you want to write data into cell A1, you could use the following:

Worksheets("YourSheetName").Activate
ActiveSheet.Range("A1").Value = formName.txtBoxName

You can also reference the worksheet by number eg
Worksheets(1).Activate
 
Glenzil, it's often best to avoid Activate and Select:
Worksheets("YourSheetName").Range("A1").Value = formName.txtBoxName.Text
 
PHV, Yes I agree your method of referencing the cell is much cleaner and tidier. I stand corrected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top