Solved

VBA string

Posted on 2014-01-23
3
311 Views
Last Modified: 2014-01-23
I did not write this code and it looks like is is looking at a string.  Where would the string be? There is no indication where at this point and it is at the top of the code.  Thanks in advance.

Sub Generate(ab As String)
Dim r As Range, impbol As Boolean 'Impact boolean
Dim dest As Range, dest_emm As Range

If ab = "Vendor" Then ' if string = vendor
  ClearTab Sheet27.Name, 2
  ClearTab Sheet23.Name, 1
  Set r = Sheet21.Range("B3")
  Set dest = Sheet27.Range("A3")
  Set dest_emm = Sheet23.Range("A3")
End If

If ab = "Broker" Then
  ClearTab Sheet26.Name, 2
  ClearTab Sheet22.Name, 1
  Set r = Sheet20.Range("B3")
  Set dest = Sheet26.Range("A3")
  Set dest_emm = Sheet22.Range("A3")
End If

End Function
0
Comment
Question by:leezac
  • 2
3 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
It's not looking for a string. It tests the value of the string that is passed into the procedure as an argument, and taking different actions, depending on which of two values it is.
0
 
LVL 80

Accepted Solution

by:
byundt earned 310 total points
Comment Utility
If you mean the string variable ab, that is being passed to the sub when it is called. To see where the value is actually coming from, you need to look at the statement that calls the sub Generate. It should be a statement like either of:
Generate "some text"
Generate SomeStringVariable

Open in new window

0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
I've just noticed that the procedure is a Sub at the start and a Function at the end. This would give a compile-time error and wouldn't run.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

762 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

6 Experts available now in Live!

Get 1:1 Help Now