Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Problem passing by reference

I am passing an integer variable into a function. In the
function I am changing the value of the variable. However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without success.
Can anyone help me?

Ted
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Problem passing by reference

Ted,

Post the code for us.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ted" wrote in message
...
I am passing an integer variable into a function. In the
function I am changing the value of the variable. However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without success.
Can anyone help me?

Ted



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Problem passing by reference

The code is below. The problem is that the rowNumber
variable never changes in the OprenReviewFiles procedure
even though I increment it in the ImportManagerReview.

Thanks for the help!

Sub OpenReviewFiles()
'
' OpenReviewFiles Macro
' Macro recorded 2/18/2004 by Ted Lapina
'

'Declare variables
Dim fs, f, f1, fc, s
Dim rowNumber As Integer

rowNumber = 2

'Select the directory where files will be imported
from.
folderspec = Application.InputBox("Please enter the
directory that contains the required filed.", "Enter
Directory Name", "f:\syd\mis\ReviewTest\")
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files

'Iterate through the files in a directory.
For Each f1 In fc
Workbooks.Open (folderspec & "\" &
f1.Name) 'Open the file
Module1.ImportManagerReview
(rowNumber) 'Run the macro
Workbooks
(f1.Name).Close 'Close the file
Next

End Sub


Function ImportManagerReview(ByRef rowNumber As Integer)
'
' ImportManagerReview Macro
' Macro recorded 2/18/2004 by Ted Lapina
'
'Import data from either the Manager Review or Peer
Review sheets.
If Range("A1").Value = "Manager Review" Then
For importRow = 6 To 15
'Copy first data row.
With Worksheets("Manager Review")
.Range(.Cells(importRow, 1), .Cells
(importRow, 52)).Copy
End With
'Paste first data row into summary spreadsheet.
With ThisWorkbook.Worksheets("Manager Summary")
.Range(.Cells(rowNumber, 1), .Cells
(rowNumber, 52)).PasteSpecial (xlPasteValues)
End With

rowNumber = rowNumber + 1
Next

Else 'Process Peer Review

End If

End Function

-----Original Message-----
Ted,

Post the code for us.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ted" wrote in

message
...
I am passing an integer variable into a function. In the
function I am changing the value of the variable.

However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer

in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without

success.
Can anyone help me?

Ted



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Problem passing by reference

It should work as you describe it. Please post code that illustrates your
dilemma.
Bob

"Ted" wrote in message
...
I am passing an integer variable into a function. In the
function I am changing the value of the variable. However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without success.
Can anyone help me?

Ted



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Problem passing by reference

There are issues with passing parameters with or without barckets/Call
statement.

NickHK

"Bob Kilmer" wrote in message
...
It should work as you describe it. Please post code that illustrates your
dilemma.
Bob

"Ted" wrote in message
...
I am passing an integer variable into a function. In the
function I am changing the value of the variable. However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without success.
Can anyone help me?

Ted







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Problem passing by reference

Not issues, syntax, but anyway that would not appear to be the problem as
Ted knows the variable doesn't change when he calls the function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Nick Cranham" wrote in message
...
There are issues with passing parameters with or without barckets/Call
statement.

NickHK

"Bob Kilmer" wrote in message
...
It should work as you describe it. Please post code that illustrates

your
dilemma.
Bob

"Ted" wrote in message
...
I am passing an integer variable into a function. In the
function I am changing the value of the variable. However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without success.
Can anyone help me?

Ted







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Problem passing by reference

Bob,
So he thinks it's being passed ByRef, but really it's being passed ByVal.

NickHK

"Bob Phillips" wrote in message
...
Not issues, syntax, but anyway that would not appear to be the problem as
Ted knows the variable doesn't change when he calls the function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Nick Cranham" wrote in message
...
There are issues with passing parameters with or without barckets/Call
statement.

NickHK

"Bob Kilmer" wrote in message
...
It should work as you describe it. Please post code that illustrates

your
dilemma.
Bob

"Ted" wrote in message
...
I am passing an integer variable into a function. In the
function I am changing the value of the variable. However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without success.
Can anyone help me?

Ted








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Problem passing by reference

Nick,

He may have declared the same name variable in his function. Who knows,
until we see the code.

Bob

"Nick Cranham" wrote in message
...
Bob,
So he thinks it's being passed ByRef, but really it's being passed ByVal.

NickHK

"Bob Phillips" wrote in message
...
Not issues, syntax, but anyway that would not appear to be the problem

as
Ted knows the variable doesn't change when he calls the function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Nick Cranham" wrote in message
...
There are issues with passing parameters with or without barckets/Call
statement.

NickHK

"Bob Kilmer" wrote in message
...
It should work as you describe it. Please post code that illustrates

your
dilemma.
Bob

"Ted" wrote in message
...
I am passing an integer variable into a function. In the
function I am changing the value of the variable. However,
the variable is not changing in the calling function.

I have specifically declared the variable as an integer in
the calling function, and I have specified byRef in the
function being called. However, the value in the calling
function still does not change.

I have tried a couple different variation without success.
Can anyone help me?

Ted










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink - Passing a cell reference buechler66 Excel Worksheet Functions 1 July 14th 06 02:15 PM
Reference problem jesmin Excel Discussion (Misc queries) 4 February 6th 06 02:08 PM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM
Passing a Range to a Function problem (still not working) Rocky McKinley Excel Programming 7 January 8th 04 12:53 AM
Passing a Range to a Function Problem Rocky McKinley Excel Programming 4 January 7th 04 02:00 AM


All times are GMT +1. The time now is 12:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"