Solved

Excel VBA pass range value

Posted on 2016-08-01
2
52 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 29

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

815 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now