Solved

Excel VBA pass range value

Posted on 2016-08-01
2
43 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
Comment Utility
Line 5: InsertPictureInRange filename, rangevalue
0
 
LVL 28

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

763 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

11 Experts available now in Live!

Get 1:1 Help Now