Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Transfer and save data from one worksheet to another.

I have a master worksheet (sheet1) that I use for several companies. What I
need to do is when I enter data into the sheet1 it will automatically be
transfered into sheet2, but i need it to save the data so that I can clear
sheet1 and still have all the data on sheet2.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Transfer and save data from one worksheet to another.

Saved from a previous post:

You'll have to change your addresses and sheet names...

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 InputWks
Set myRng = .Range(myAddresses)
End With

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

With HistoryWks
NextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
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
.Cells(NextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clean up data in form??
myRng.ClearContents

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.

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


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

arepemko wrote:

I have a master worksheet (sheet1) that I use for several companies. What I
need to do is when I enter data into the sheet1 it will automatically be
transfered into sheet2, but i need it to save the data so that I can clear
sheet1 and still have all the data on sheet2.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Transfer and save data from one worksheet to another.

Thank you very much.

Dave Peterson wrote:
Saved from a previous post:

You'll have to change your addresses and sheet names...

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 InputWks
Set myRng = .Range(myAddresses)
End With

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

With HistoryWks
NextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
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
.Cells(NextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clean up data in form??
myRng.ClearContents

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.

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

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

I have a master worksheet (sheet1) that I use for several companies. What I
need to do is when I enter data into the sheet1 it will automatically be
transfered into sheet2, but i need it to save the data so that I can clear
sheet1 and still have all the data on sheet2.



--
Message posted via http://www.officekb.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
emailing excel worksheet with data protected? sewsew8591 New Users to Excel 2 July 11th 06 07:39 PM
save page setup settings to transfer from 1 worksheet to another bassett76 Excel Discussion (Misc queries) 5 February 22nd 06 12:40 PM
How can I create a button to save one worksheet into a new workshe court Excel Discussion (Misc queries) 2 July 6th 05 06:39 PM
Help - now really stuck! File transfer problem ohboy! Excel Discussion (Misc queries) 10 May 2nd 05 09:07 PM
How do I collect data from an interactive web worksheet and impor. worksheetmom Excel Discussion (Misc queries) 3 February 20th 05 12:38 AM


All times are GMT +1. The time now is 10:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"