View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Saved from a previous post--you'll have to change your addresses:

Option Explicit
Sub testme01()

Dim historyWks As Worksheet
Dim inputWks As Worksheet

Dim nextRow As Long
Dim oCol As Long

Dim myRng As Range
Dim myAddresses As String
Dim myCell As Range

myAddresses = "A1,F9,A2,B1"

Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Summary")

With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With inputWks
Set myRng = .Range(myAddresses)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
myCell.ClearContents 'clean it up???
oCol = oCol + 1
Next myCell
End With

End Sub

I check to see if all the cells have something in them (maybe not required???).

I also add the date/time to column A of the summary sheet and the username
(taken from Tools|options|General tab) to column B.

Then Column C to xxxx go in the same order as the addresses you've specified in
this line:

myAddresses = "A1,F9,A2,B1"

(Change that to match your input worksheet.

(mycell.clearcontents may not be necessary, too.)

lunker55 wrote:

I have a sheet where I enter text and values into various cells. After all
cells are entered, I want to copy certain cells into 1 row in another sheet
in the same book.
Every time I enter information in the cells in the first sheeet, I want to
put those values in the next available row in the second sheet.
ie: Sheet1! A1,B15,B16,B17,G7,B22 (always the same cell numbers) Copy into
Sheet2! A1,B1,C1,D1,E1,F1 the first time, then the new values into cells
A2,B2,C2,D2,E2,F2
And so on.
Does anyone have a macro or know where to look to read up on how to do it.
Any info would be great.
Thanks,
Joe


--

Dave Peterson