Transferring of certain cells from one workbk to another
The line mentioned can not stand alone, it's a part of the line:
Cells(TargetRow, "A").Copy _
Destination:=wbB.Sheets("Sheet1").Range("C16")
Notice the "_" sign indication that the two lines should be seen as one
statement and can be entered as such.
If this don't help you can mail me a sample workbook with the code in.
Regards,
Per
"amelia" skrev i meddelelsen
...
Destination:=wbB.Sheets("Sheet1").Range("C16")
A pop-up error box(message shown below) appears when I type the above-
compile error:
Expected: expression
And it doesnt get activated at all.
Yup, Ive placed the code where the user selects the thickness and and save
it as macro enabled workbook.
Thanks.
"Per Jessen" wrote:
It works for me.
When you say, that you can't get the macro to work, does it mean that it
throws an error, or doesn't it get activated at all.
Is the macro placed in the code sheet for the sheet where the user select
the thickness?
You are right about wbB using excel 2007. Is the workbook containing the
macro saved as an macro enabled workbook ?
Regards,
Per
"amelia" skrev i meddelelsen
...
I've tried programming it but it cant seems to work. I have no idea
where
I
go wrong:< By the way, I am using excel 2007, so it should be: Set wbB
=
Workbooks("Book2.xlsx") right? Does it work for you?
"Per Jessen" wrote:
Ok there is no click event which can be used, but we can use a
Double_Click or Right_Click event.
Only one of the two first lines shall be used, the other is to be
deleted. Inset the code as described in previous post.
I still assume that values shall be pasted into sheet1 of wbB.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel
As Boolean)
Dim wbA As Workbook
Dim wbB As Workbook
Set wbA = ThisWorkbook
Set wbB = Workbooks("Book2.xls") 'change to desired name
Set isect = Intersect(Target, Range("B12:B59"))
If Not isect Is Nothing Then
TargetRow = Target.Row
Cells(TargetRow, "A").Copy _
Destination:=wbB.Sheets("Sheet1").Range("C16")
Cells(TargetRow, "D").Copy _
Destination:=wbB.Sheets("Sheet1").Range("N16")
End If
End Sub
Hopes it helps
Regards,
Per
|