Kristofferson
New Member
- Joined
- Dec 2, 2016
- Messages
- 2
Hi all,
I'm very new to VBA and am struggling with a macro as per the subject line after searching on forums and playing with it all day so any help would be greatly appreciated thanks!
I have a colleague who will provide a monthly output to excel that I need to enter into a continual log. I have set up an Input page for this person to copy and paste into and would like to then transfer this data into the next available rows in a Log sheet. I have got as far as copying the data over but after trying many ways of setting the last available row to copy the data to with .End(xlUp) in various places within the code I still can't get it right. Any help would be gratefully received.
Code so far (without trying to paste to the last availabe row) is:
Sub CopyInputtoLog()
'Copies data pasted into Input sheet into Cases Log sheet and clears the input page
Dim shtInput As Worksheet, shtLog As Worksheet
Dim rngInput As Range, rngLog As Range
Set shtInput = ThisWorkbook.Worksheets("Input")
Set shtLog = ThisWorkbook.Worksheets("Cases Log")
Set rngInput = shtInput.Range("A2:N497")
Set rngLog = shtLog.Range("B4:O500")
rngInput.Copy
rngLog.PasteSpecial (xlPasteValues)
rngInput.ClearContents
shtInput.Range("$A$1").Value = "Paste as values here"
End Sub
(It's so small!)
Any direction would be great as I've searched the forums and none of the solutions seem to work for me. Apologies for the newbiness, go gentle, it's my first try at VBA!
Thanks very much.
I'm very new to VBA and am struggling with a macro as per the subject line after searching on forums and playing with it all day so any help would be greatly appreciated thanks!
I have a colleague who will provide a monthly output to excel that I need to enter into a continual log. I have set up an Input page for this person to copy and paste into and would like to then transfer this data into the next available rows in a Log sheet. I have got as far as copying the data over but after trying many ways of setting the last available row to copy the data to with .End(xlUp) in various places within the code I still can't get it right. Any help would be gratefully received.
Code so far (without trying to paste to the last availabe row) is:
Sub CopyInputtoLog()
'Copies data pasted into Input sheet into Cases Log sheet and clears the input page
Dim shtInput As Worksheet, shtLog As Worksheet
Dim rngInput As Range, rngLog As Range
Set shtInput = ThisWorkbook.Worksheets("Input")
Set shtLog = ThisWorkbook.Worksheets("Cases Log")
Set rngInput = shtInput.Range("A2:N497")
Set rngLog = shtLog.Range("B4:O500")
rngInput.Copy
rngLog.PasteSpecial (xlPasteValues)
rngInput.ClearContents
shtInput.Range("$A$1").Value = "Paste as values here"
End Sub
(It's so small!)
Any direction would be great as I've searched the forums and none of the solutions seem to work for me. Apologies for the newbiness, go gentle, it's my first try at VBA!
Thanks very much.