Macro to add data

A

Arlene

I want a macro to carry my information from a form into a spreadsheet. The
data needs to go into the first line of the spreadsheet each time new data is
entered on the form. In the spreadsheet itself, I need to add a row, moving
existing data into the rows below, and add whatever new data id obtained from
the form. Once that is done, I need to clear the form.
 
F

FSt1

hi
assuming that you are using a standard userform from the vb editor......
you will need a line like this for each of your controls that you have
entered data into and want that data to go to the sheet.

Range("A65000").End(xlUp).Offset(1, 0).Value = TextBox1.Value

then to clear the form you would need a line like this for each control to
clear the control......

TextBox1.Value = ""

i assume that all these lines would go into a commandbutton_click event.

post back if questions.

Regards
FSt1
 
F

FSt1

forgot to add
adjust the range for each line of code to the column you want the data to go
into.

regards
FSt1
 
A

Arlene

This is the code that I have and what happens is that the top row is
replaced, not copied down

Sub AddRecord()
'
' AddRecord Macro
'
' Keyboard Shortcut: Ctrl+Shift+R
'
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(-1, 0).Range("A1:G1").Select
Selection.Copy
Application.Goto Reference:="Bottom"
ActiveCell.Offset(-1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Sheet1").Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top