Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel VBA pass range value

Posted on 2016-08-01
2
Medium Priority
?
88 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

Expert Comment

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

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

618 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