Call Procedure And Pass Range Info

Mar 22, 2007

Have a spreadsheet for creating employee schedules (any number of employees, 3 rows per employee, 5 columns for each day). I want to move all employees' info for one day (5 columns and XX rows) to another area and then clear the employees' data for that day. I have the code working for Monday but I don't want to duplicate it 6 more times for Tue -Sun. I have set up named ranges (i.e. MonFT, TueFT, etc.

I would like to call one subprocedure to do this and pass parameters for each day so the ranges can be changed to reflect the desired day?

I am doing this for holidays; i.e. if there is a Wed. holiday, store all of Wednesday's data and clear Wed. Then restore all Wed data when preparing the schedule for the following week.

View 7 Replies


ADVERTISEMENT

Pass WB / WS / Range Info From Cell To VBA Procedure?

May 31, 2013

I need to pass range information (eg. WorkSheets("abc").Range("A1") as text or ??) from a cell (ie the above text is in a cell on some worksheet, say "XYZ") to a VBA procedure or could directly use it in the procedure, similar to...

Sub MyProc(RngInfo as string [or?])
dim RRng as range
Set RRng= RngInfo ??? it is this part I'm really not sure how to do

where RngInfo is a worksheet that has a "named" cell that contains the above cell with the indicated range in it.

eg. RngInfo is worksheets("XYZ").Range("D1") where D1 contains the text (or ?)WorkSheets("abc").Range("A1")

I've only indicated these as text items because I'm not sure what/how you would do this. The end purpose of this is to pass variable Range information from a cell on a WS either into (or use within directly) a VBA Sub. I guess I could pass the WS and Range Address as a single string separated by a "Char" and use Split to separate them and then recombine using Worksheets(Parm(0)).Range(Parm(1)) but it seems like it should be easier than that.

View 9 Replies View Related

Pass Value From Function To Procedure

Aug 11, 2006

If I have code like this

Private Sub cmdHex_Click()
Dim HexNum As String
HexNum = Me.txtHexVal
'Call a function
ToBinary (HexNum)
'Now do something else
End Sub

And the function ToBinary creates a value called BinVal. How do I pass it back to my subprocedure to do something with it.

View 4 Replies View Related

Pass More Than One Argument To Procedure

Dec 11, 2006

I want to be able to call a procedure and pas 2 variables that it will need to it.
The code looks like this:


Private Sub UpdateScreen(StartLine As Byte, EndLine As Byte)

End Sub
UpdateScreen(104 , 140)

For some odd reason I get an "Expected: = "error when I enter the last line. I works if I send only one variable, but not when I send 2.

View 2 Replies View Related

Call Procedure From Add-in

Nov 27, 2007

I have a userform in an add-in (which is loaded), when I try and call it from an excel sheet, I get the following error "Variable not defined"

Private Sub CommandButton3_Click()

UserForm1.Show

End Sub

The code in the userform is all private subs.

Similarly when calling a public sub from the add-in such as;

Private Sub CommandButton3_Click()

Call SillySub

End Sub

I get the error "Sub or Function not defined".

How should I be doing this?

View 3 Replies View Related

Call A Sub Procedure From Another

Jun 19, 2008

how do you call another sub's function from another sub? For example:

Sub Worksheet_SelectionChange(ByVal Target As Range)

StartingDate:
Static STempHolding As String
If STempHolding <> "" Then OldStartingDate = STempHolding
STempHolding = Target.Value

EndingDate:
Static ETempHolding As String
If ETempHolding <> "" Then OldEndingDate = ETempHolding
ETempHolding = Target.Value

End Sub

If i just wanted to call the StartingDate function, from my Worksheet_Change sub how would i do that?

View 5 Replies View Related

Pass Userform To Public Sub Procedure

Feb 15, 2010

I have a userform that has a number of cascading comboboxes, however i wish to use the same cascading feature in a number of other userforms. So what i am trying to achive is calling the cascading element from a public macro, to do this i need to pass the userform name to the procedure. The snippet of code i am using is:

Form:
Private Sub ComboBox1_Change()
If ComboBox1.Value <> "" Then
myform = Me.Name
Call Cascade1(myform)
End If
End Sub

Module:
ub Cascade1(myform)
myform.Label2.Visible = True
myform.ComboBox2.Visible = True
myform.ComboBox2.RowSource = Range(myform.ComboBox1.RowSource).Cells(myform. ComboBox1.ListIndex + 1, 1)
End Sub

View 2 Replies View Related

Pass Multiple Arrays To Procedure

Sep 10, 2007

I have a procedure that I want to pass two arrays to. When I pass a single array it works fine but as soon as I try to pass two arrays I get a syntax error. Both arrays are declared exactly the same way and are used in the same way. Am I limited to passing only one array per procedure?

View 8 Replies View Related

Pass Cell In Loop To Procedure

Jan 1, 2008

I want to put some colour in the cells B2, B3, B4, B5, etc and a put black the edge of every box. For do that i make a subrutime that put some color in the range that i want (only if i write "B2" or "B2:B5"), but if i want to put a black edge in all the box i can't do "B2:B5". Then i tried to do something like:

For i=2 To 5 Step 1
Call Boxcute(ActiveSheet.Cells(i,2))
Next i

Sub Boxcute (Box As String)
Range(Box).Selection
etc.
End Sub

But Excel gives me a error with Box and Range.

View 2 Replies View Related

How To Call A Procedure / Function

Mar 2, 2012

I have found some code that does what I want- but i do not understand how to use - call it. The programmer says ...

GetNetworkIPAddress()
' can be called from a worksheet cell using the formula:
' =GetNetworkIPAddress()

I have put this in a cell but i ger an error #Name?

what should i do ?

View 9 Replies View Related

Invalid Procedure Call Using ASC

Jan 27, 2008

I am getting an invalid procedure call when the portion of the code that has the ASC function runs. The only change I made to the workbook was to increase the available rows that this macro is totaling from 150 to 300. If I don't increase the rows I do not get the error.

What this code is doing is grouping information from 20 different sheets and totaling them and placing the total in the correct group. Most of the totals will begin with a number, however there will be a small amount that will begin with a letter. The items with letters need to be grouped in the 17000 category.

Dim c As Range
Dim rng As Range
Set rng = Range(Cells(3, "R"), Cells(lastrow, "R"))
For Each c In rng

If c < 20 Then c.Offset(0, 1) = "01000"
If (c > 19) * (c < 26) Then c.Offset(0, 1) = "02000"
If (c > 25) * (c < 161) Then c.Offset(0, 1) = "02600"
If c > 159 Then c.Offset(0, 1) = WorksheetFunction.Text(c, "000") & "00"
If Asc(Left(c, 1)) > 58 Then c.Offset(0, 1) = "17000"
If c > 170 Then c.Offset(0, 1) = "18000"
Next c

View 9 Replies View Related

CALL STORED PROCEDURE FROM VB

Feb 12, 2009

I need to call a Stored Procedure in a SQL Server from VB, but do not have the minimun Idea about doing it....Could you help me ?...I made a lot of attemps copiying code from other treads and scratch it, but so far results = none.

Server name: VAIO/SERVIDOR
DataBase: CEDRO
I´m using Excel XP.

View 9 Replies View Related

Call Procedure From Another VBA Project

Sep 21, 2006

In my VBA Project I try to call procedure from another VBA Project, but I get syntax error. The code is like: call Automation.xls!convert_numb

View 2 Replies View Related

Use A Variable To Run Or Call A Procedure By Name

Sep 8, 2007

I have 46 drop downs that I need to call from a main sub. I want to create one loop that will call each one to perform its function. Below is a simple example of what I am trying to do, but where I need help is with the 'Call Y' line. I am not sure what character to use to tell excel to look at what is in the value of Y, not 'Y' itself

Sub testitout()
Dim y As String

For X = 1 To 2
Sheets(" Lookup"). Range("E3").Value = X + 4
y = "dropdown" & X & "_change()" 'this will return "dropdown1_change()" for the first loop
Call y 'i want to call dropdown1_change() below
Next

View 9 Replies View Related

Calling Stored Procedure And Pass Through A Paramter?

Apr 27, 2007

Is it possible to call a stored proc from excel and pass through a paramter?

If it is would anyone have a clue how to do this?

View 11 Replies View Related

Invalid Procedure Call Or Argument

Nov 7, 2007

This error occured me, and i clicked "Debug" to see where was the error and i found a strange thing that i don't know how to solve it:
The line has the following

View 10 Replies View Related

Invalid Procedure Call Or Argument On Second Run

Jan 10, 2007

I have some VBA that appears to work perfectly on the first run, but I get the following error if I run it again or any alternate runs;

Title: Error (App_WorkbookBeforeClose)
Number: 5
Message: Invalid procedure call or argument

The only way my code currently works is if Excel has just been launched. The VBA creates, saves and modify's files so I imagine it has something to do with the ThisWorkbook object when a file is being saved or closed. I have googled the error but didn't really get anywhere as it is pretty generic and seems to be returned for a number of Excel products.

View 2 Replies View Related

Call / Run Commad Button Procedure

Jan 10, 2008

Is it possible to call a Forms Command Button procedure from a Module?

View 3 Replies View Related

Dir Function - Invalid Procedure Call Or Argument

Jun 25, 2013

When I step-through my code below, it always opens the first file in the directory "C:Pyramid Files", but when it comes back to the Pyramid Files sub after fully processing the first file via various other subs, the VB Editor apparently doesn't like something about this line: StrFile = Dir(), since it quits after "snapping-back" to the previous sub Initialize(). I have also tried StrFile = Dir, but that doesn't work either. I did Dim Strfile in the General Declarations. When I set Watches for Dir and Dir(), I get the value "Invalid procedure call or argument" for both, as if the directory function lost the value. I can't determine why this is happening.

VB:
Dim WSM As Worksheet, WSB As Worksheet, WS1 As Worksheet, [U]StrFile As String[/U], StrDirectory As String, ClientCode As String
Dim Filename As String, LastRowb As Long, LastColB As Integer, LastRow1 As Integer, NextRowC As Integer, x As Integer, y As Integer

[Code] .......

View 4 Replies View Related

Invalid Procedure Call Or Argument In Function

Aug 30, 2012

This error message in line vpp:

Invalid procedure call or argument

Code:
Function fn1(ByVal a, ByVal i, ByVal e, ByVal N, ByVal w, ByVal ta)
Pi = Application.WorksheetFunction.Pi
mhu = 398600
vpp = (mhu / Math.Sqr(mhu * a * (1 - e ^ 2))) * (-Math.Sin(ta * Pi / 180))
fn1 = 2 * vpp
End Function

View 9 Replies View Related

Auto Call A Procedure By Selecting From A Dropdown List

Oct 30, 2008

I have a worksheet with a Drop Down list (Set up with Data Validation).

All I want to do is a call a procedure when a particular option is selected from the list, without have to run the macro manually.

View 7 Replies View Related

Run-time Error '5' Invalid Procedure Call (CommandBars)

Nov 13, 2009

I create and load a commandbar, prior to loading it I attempt to check if it exists, then delete it, and recreate.

I dont understand why this seemed to work for months and now creates an error.
It appears that every now and then the created commandbar is not created when I open a file. Thats when the error pops up. I can manually run the Create_Bar sub and it will be fine, for a while.

Run-time error '5':
Invalid procedure call or argument

This section is in my personal.xls file in "ThisWorkBook" of personal.xls.

View 5 Replies View Related

Runtime Error - Invalid Procedure Call Or Argument

Jun 24, 2014

Code:
Dim LR As Long Dim Dash As Long, _
Whole As Double
Dim pi ', WorkSheets, Range
WorkSheets("Sheet3").Select
LR = Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Row

[Code] .........

View 2 Replies View Related

Invalid Procedure Call Or Argument Referencing Files

Nov 6, 2006

I am using a procedure to loop through all files in a folder and am encountering an

Invalid procedure call or argument, error on the ChDrive line:

mypath = "\Eo1
_iSurveysNALCReturns"
ChDrive mypath

Is it something to do with the mypath syntax? Recently our drives have been reorganised. I used to just use "G:Surveys..." which always worked. Does anyone have any thoughts? I hope I've explained properly - you can probably tell I don't know much about this sort of thing.

View 5 Replies View Related

Pass Variable To A Call Subroutine

Jan 18, 2007

I have a code below which need some input from user. This input will also be serve as the input of the subroutine which i am going to call. However, i do not know how to go assign this input to the subrountine which i will be calling, can anybody help ?

For example, the "input" variable will also be served as an input in subroutine test2 ...

View 6 Replies View Related

Invalid Procedure Call Or Argument Adding Conditional Format Condition

Oct 4, 2006

I would like to apply different conditional formatting at different times with a click of a button. I setup a dummy and turned on the recorder and recorded this

Range("A7:N7").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$C7=1"
Selection.FormatConditions(1).Interior.ColorIndex = 37
Range("A1").Select
End Sub

I tried changing to this

'/Conditional Format - OTHER EXPENSE B/L
Set rngConditional = wsData.UsedRange
With rngConditional...............

View 9 Replies View Related

Procedure To Return A Range

Jul 25, 2006

I want to write a procedure similar to MMULT. I find that

Public Function aa_ok(arg1 As Range)

works to get the data.

I have not been able to figure how to get the result back to the spreadsheet.

Documentation sez that args are passed by ref, but I am unable to modify args and see the change in the spreadsheet (thank god).

I find that statements like

aa_ok = Worksheets("Sheet1").Range("A1").Value

work just fine but statements like

Worksheets("Sheet1").Range("A5").Value = Worksheets("Sheet1").Range("A1").Value

don't, even though I copied that statement from the help system.
I tried

Function calculate(ByRef X As Range, ByRef Y As Range)
calculate = X * Y
End Function

which I got here - and it doesn't work on my system.

I get a block of cells with repeats of #VALUE! where I expect my result to be displayed.

I have Excel 2000 9.0.2720 and VBA Retail 6.0.8714

I have looked at security and it is set low.

View 6 Replies View Related

Execute Procedure Whenever A Range Is Copied

Apr 22, 2008

how I can have a routine execute whenever a cell range is copied in excel. Doesn't matter whether by selecting the appropriate menu item or when CTRL+C is pressed (I mean it must work anyway).

I need this cause I would like to store in a public variable the address of the range which is being copied in order to use it later for undoing purposes.

I first tried to find a way of accessing what has been copied into the clipboard but it doesn't seem possible without using external DLLs.

View 3 Replies View Related

Get Range To Pass Into Function

Jun 11, 2009

I am attempting to call a Function from a cell and pass it a range and an Integer. The Integer works fine, but I cannot get the Range to pass into the function correctly.

View 8 Replies View Related

Pass The Variable In The Range

Jul 25, 2008

I want to work on a range

range("A1:B100")

The number 100 (in B100) comes from another varibale M

Now how do I write the range so that I don't have to write 100. I want to pass on the variable in the range.

the code should look somewhat like

Range("A1:BM").

I don't know how to pass this variable M onto the range.

View 30 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved