Copying Data from one table to another

KlayColgrove

New Member
Joined
Oct 19, 2018
Messages
12
I am trying to get inputted data from one worksheet to another. I want to be able to enter different values in the worksheet "Add Line" that will transfer over to the last row in "Work Order Lines" with the corresponding values. I am relatively new to VBA and have been doing research on the subject and haven't been able to solve this problem
Code:
Dim ws As Worksheet
Dim wol As Worksheet
Set ws = ActiveWorkbook.Sheets("Add Line")
Set wol = ThisWorkbook.Sheets("Work Order Lines")



ws.Range("C3").Copy
wol.Range("B" & lRows).PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
I keep getting an error on the last line. I got most of the code from other forums, so I could be adding in variables that I have not added myself.
Any help would be great
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try:

Code:
Sub CopyPaste()
 Dim ws As Worksheet, wol As Worksheet[COLOR=#ff0000], lRows As Long[/COLOR]
  Set ws = ActiveWorkbook.Sheets("Add Line")
  Set wol = ThisWorkbook.Sheets("Work Order Lines")
   ws.Range("C3").Copy
  [COLOR=#ff0000] lRows = wol.Cells(Rows.Count, 2).End(3).Row[/COLOR]
   wol.Range("B" & lRows [COLOR=#ff0000]+ 1[/COLOR]).PasteSpecial Paste:=xlValues
End Sub
or
Code:
Sub Replicate()
 Sheets("Work Order Lines").Cells(Rows.Count, 2).End(3)(2) = Sheets("Add Line").[C3]
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top