Solved

Excel VBA pass range value

Posted on 2016-08-01
2
57 Views
Last Modified: 2016-08-01
I have the following
Sub TestInsertPictureInRange()
  Dim filename As String:  filename = Cells(1, 11)
  Dim rangevalue As Range: Set rangevalue = Range(Cells(1, 12), Cells(1, 13))

  InsertPictureInRange(filename, rangevalue)
    
End Sub

Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range)

End Sub

Open in new window


However, when I put in "rangevalue" in the call to:
InsertPictureInRange(filename, rangevalue)

I get an error:
Compile error:
Expected: =

How should I be passing this?
0
Comment
Question by:maverick0728
2 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 41737443
Line 5: InsertPictureInRange filename, rangevalue
0
 
LVL 30

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
ID: 41737455
You need to remove the parenthesis around the arguments.
When you call a procedure without using the keyword Call, you don't need to specify the arguments inside the parenthesis.

So you should use one of the following method to call another procedure...

InsertPictureInRange filename, rangevalue

Open in new window


OR

Call InsertPictureInRange(filename, rangevalue)

Open in new window

1

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question