vba syntax error with passing string

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

can you please advise why im getting an error

Im trying to pass a string address and then use that put it aint working

'Calling function
UpdatePCA ThisWorkbook.Worksheets("Calc").Range("PCA_CS"), "D7:K7"

Code:
Private Sub UpdatePCA(PCA_File As String, PCA_Address As String)


Dim WeeklyReviewSh As Worksheet
Dim Lweek As Worksheet
Dim PCA_WB As Workbook


Set Lweek = ThisWorkbook.Worksheets("Last Week")


Application.ScreenUpdating = False


    Set PCA_WB = Workbooks.Open(PCA_File, , True)
    Set WeeklyReviewSh = PCA_WB.Worksheets("WeeklyReview")
    
    'Actual PCA
   >>>This is where i get an error Lweek.Range("PCA_Address").Value = WeeklySh.Range("C15:J15").Value


    'Close File
    PCA_WB .Close False
    
Application.ScreenUpdating = True




End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Remove the quotes from the first range argument

Code:
Lweek.Range(PCA_Address).Value = WeeklySh.Range("C15:J15").Value
 
Upvote 0
Hi,
remove the Quote (speech) marks around your argument

Rich (BB code):
Lweek.Range("PCA_Address").Value = WeeklySh.Range("C15:J15").Value

Dave
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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