Copying Data

KenPopcorn

New Member
Joined
Nov 16, 2009
Messages
9
I swear this worked at one point but now gives a '1004' runtime error. What I am trying to accomplish is have the user display a line of data on a userform, modify it, then write it back to another sheet in the workbook.

My code:

Sub WriteData()
Dim target As Long
ActiveScreenUpdating = False
target = Range("B19").Value
'
If target > Sheets("WORK").Range("B3") Then
MsgBox ("Invalid Line Number")
GoTo ExitSub
End If
Sheets("GROUP 1").Range(target, 1) = Range("D19")
Sheets("GROUP 1").Range(target, 4) = Range("F19")
Sheets("GROUP 1").Range(target, 3) = Range("H19")
Sheets("GROUP 1").Range(target, 5) = Range("J19")
Sheets("GROUP 1").Range(target, 11) = Range("D22")
Range("B19").Activate
ExitSub:

End Sub

Please help this noob!

Thanks
 
If I work with fixed cells like this (not too many) then I give each cell a name, and use the name in the macro (Range("MyName")). That way if I delte or add rows or columns, the macro still works.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,470
Latest member
Subhash Chand

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