Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing a range to a function

Formul in Excel looks like this:
=TestForEach(F7:J8)

Function TestForEach(a As Range)
Dim cell As Range
For Each cell In Range(a)
Msgbox("Hello")
Next
End Function

Whats worg with this picture. I am trying to pass a range of cells from
excel to this function and nothing happens. For some reason I am not using
the "a" range correctly.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Passing a range to a function

David

Not sure what your function does but a is already set to a range so just use
a

Function TestForEach(a As Range)
Dim cell As Range
For Each cell In a
Msgbox("Hello")
Next
End Function


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"David Bell" <David
wrote in message
...
Formul in Excel looks like this:
=TestForEach(F7:J8)

Function TestForEach(a As Range)
Dim cell As Range
For Each cell In Range(a)
Msgbox("Hello")
Next
End Function

Whats worg with this picture. I am trying to pass a range of cells from
excel to this function and nothing happens. For some reason I am not using
the "a" range correctly.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Passing a range to a function

I need to check a range of cells for materials choosin for a beam,
ie. DF, DF #2 & Btr, DF #1, PSL, LVL, ect

They may select 1 or several materials to use for the beam check.
The user needs to send me a range where the materials are specified and then
I will do calculations to determine the min size and material for the beam
and / or give them a choice of all amterials and sizes allowable

Formula in Excel looks like this:
=TestForEach(F7:J8)

Function TestForEach(a As Range)
Dim cell As Range
For Each cell In Range(a)
'Msgbox("Hello")
Call CalculatMinimumBeamSize(cell, returnvalue)
Next
End Function

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Passing a range to a function

I got it working, Thanks for the help. The problem was the "in a" instead of
"Range(a)" and using "cell" for the data
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
Passing a range to a function Isabelle[_2_] Excel Programming 1 January 23rd 06 10:24 PM
Passing a range into a VBA function Floyd[_2_] Excel Programming 4 February 10th 05 01:29 AM
Passing range as an argument in a function Hari[_3_] Excel Programming 1 June 15th 04 02:41 AM
Passing a Range to a Function Problem Rocky McKinley Excel Programming 4 January 7th 04 02:00 AM
Passing an unkown range to a function Newbie3333 Excel Programming 3 December 5th 03 02:14 AM


All times are GMT +1. The time now is 02:09 AM.

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

About Us

"It's about Microsoft Excel"