Code Error

Dolemitefunk

New Member
Joined
Oct 12, 2010
Messages
47
Can someone please tell me what is wrong with my coding?

Sub Autocopy36()
Dim master As Workbook
Dim factors As Worksheet

Set master = ActiveWorkbook
Set factors = master.ActiveSheet

Set Test= Workbooks.Open("U:\Me\docs.xlsx")

Set Result= Test.Worksheets("Numbers")


Result.Range("H14").Select
ActiveCell.FormulaR1C1 = "=factors.C31"
Range("H14").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Can someone please tell me what is wrong with my coding?

Sub Autocopy36()
Dim master As Workbook
Dim factors As Worksheet

Set master = ActiveWorkbook
Set factors = master.ActiveSheet

Set Test= Workbooks.Open("U:\Me\docs.xlsx")

Set Result= Test.Worksheets("Numbers")


Result.Range("H14").Select
ActiveCell.FormulaR1C1 = "=factors.C31"
Range("H14").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub

I think it is because you didn't specify which sheet you are working on.

Try

Code:
With Sheets("Numbers")
Result.Range("H14").Select
    ActiveCell.FormulaR1C1 = "=factors.C31"
    Range("H14").Select
    Selection.Copy
    Range(Selection, Selection.End(xlDown)).Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
End With
End Sub
 
Upvote 0
For this macro I am trying to open another file, select cell H14, link that cell to the worksheet the macro is in at Cell C31. I did this witht he record function at first , and it ended up giving me code that offseted a cell from a reference point, and I wanted it to be a specific cell (C13)...I hope that makes sense
 
Upvote 0
For this macro I am trying to open another file, select cell H14, link that cell to the worksheet the macro is in at Cell C31. I did this witht he record function at first , and it ended up giving me code that offseted a cell from a reference point, and I wanted it to be a specific cell (C13)...I hope that makes sense


I am also new to using VBA, but from what I know when you use the .FormulaR1C1 you must refer to cells in terms of row(R) and column (C).

For an absolute reference to H15 using the R1C1 notation use: R15C8.


Similarly, for an absolute reference to cell C31 use: R31C3 (31st row, column 3)

The difference is the lack of brackets [], when the brackets appear that is when the cell reference is "offseted".

So try using these absolute references with the recorded macro and see if they work for you now.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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