View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Arlene Arlene is offline
external usenet poster
 
Posts: 38
Default Macro to add data

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

--
Arlene


"FSt1" wrote:

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

regards
FSt1

"FSt1" wrote:

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
"Arlene" wrote:

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.
--
Arlene