I am new to macros, I need some help as to how do I add code to a working macro to accomplish an additional function.
What I have is workbook1 SalesTracker, 15 rows in column A and B the data is cut then pasted to workbook2 sheet2 by clicking a button. My code for this is working fine. The problem is every time I run the macro it overwrites the previous data. I need to be able to add to the previous data in workbook2 Sheet2. I have found code that is supposed to look for blank cells in the column that the data is in and paste the new data in blank cells.
I’m not sure where or what mods I need to make to the code to get two different macros running as one macro, or een i is i posible. Can anyone point me in the right direction?
Here is the code I’m using that works fine that I have in Module2:
Sub CutPaste()
'
' CutPaste Macro
'
'
Range("A1:B14").Select
Selection.Copy
Windows("TrackerReports.xlsm").Activate
Range("A2:B15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Windows("Tracker.xlsm").Activate
Range("A2:A13").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A2").Select
End Sub
Also this code is tied to the above code in Module1:
Private Sub CommandButton1_Click()
Dim LastRw As Long
LastRw = Sheets("Sheet2").UsedRange.Rows.Count
Sheets("Sheet2").Cells(LastRw + 1, "A").Value = Sheets("Sheet1").TextBoxes("TextBox 1").Text
Sheets("Sheet2").Cells(LastRw + 1, "B").Value = Sheets("Sheet1").TextBoxes("TextBox 2").Text
Sheets("Sheet2").Cells(LastRw + 1, "C").Value = TimeValue(Now)
End Sub
This is the code I’m trying to tie in, but not sure where of how to mod the code above to tie it in:
Option Explicit
Sub saleschartnew()
'
' saleschartnew Macro
' Macro recorded 19/04/2007 by Network Services
Dim wsTo As Worksheet
Dim wsfrom As Worksheet
Dim rnextCl As Range
Set wsfrom = Sheets("Entry form")
Set wsTo = Sheets("Monthly Sales Chart")
Set rnextCl = wsTo.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0)
rnextCl.Value = Range("G3")
rnextCl.Offset(0, 1).Value = Range("C13")
rnextCl.Offset(0, 2).Value = Range("E20").Value
Sheets("Entry form").Select
End Sub
What I have is workbook1 SalesTracker, 15 rows in column A and B the data is cut then pasted to workbook2 sheet2 by clicking a button. My code for this is working fine. The problem is every time I run the macro it overwrites the previous data. I need to be able to add to the previous data in workbook2 Sheet2. I have found code that is supposed to look for blank cells in the column that the data is in and paste the new data in blank cells.
I’m not sure where or what mods I need to make to the code to get two different macros running as one macro, or een i is i posible. Can anyone point me in the right direction?
Here is the code I’m using that works fine that I have in Module2:
Sub CutPaste()
'
' CutPaste Macro
'
'
Range("A1:B14").Select
Selection.Copy
Windows("TrackerReports.xlsm").Activate
Range("A2:B15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Windows("Tracker.xlsm").Activate
Range("A2:A13").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A2").Select
End Sub
Also this code is tied to the above code in Module1:
Private Sub CommandButton1_Click()
Dim LastRw As Long
LastRw = Sheets("Sheet2").UsedRange.Rows.Count
Sheets("Sheet2").Cells(LastRw + 1, "A").Value = Sheets("Sheet1").TextBoxes("TextBox 1").Text
Sheets("Sheet2").Cells(LastRw + 1, "B").Value = Sheets("Sheet1").TextBoxes("TextBox 2").Text
Sheets("Sheet2").Cells(LastRw + 1, "C").Value = TimeValue(Now)
End Sub
This is the code I’m trying to tie in, but not sure where of how to mod the code above to tie it in:
Option Explicit
Sub saleschartnew()
'
' saleschartnew Macro
' Macro recorded 19/04/2007 by Network Services
Dim wsTo As Worksheet
Dim wsfrom As Worksheet
Dim rnextCl As Range
Set wsfrom = Sheets("Entry form")
Set wsTo = Sheets("Monthly Sales Chart")
Set rnextCl = wsTo.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0)
rnextCl.Value = Range("G3")
rnextCl.Offset(0, 1).Value = Range("C13")
rnextCl.Offset(0, 2).Value = Range("E20").Value
Sheets("Entry form").Select
End Sub