LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA function modify a range

Hi,

I am sorry if this is a too basic question. Unfortunately I couldnot find a
solution so far.

I wish to write a function in VBA which would modify the cells (which is
passed as a parameter) and also return a value. Something like this:

Public Function macro1(add As Range)as String
add.Select
Selection.Value = 10
macro1="hello"
End Function

But this does not work. "add.Select" does not seem to have any effect.

But if I write it as a Sub, it works

Public Sub macro1(add As Range)
add.Select
Selection.Value = 10
End Sub

But I actually need this to be a function.

Any help or pointer would be greatly appreciated.


Thanks.


 
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
Modify range of cells at once... Andrey Kazak New Users to Excel 6 November 6th 09 08:53 PM
Modify search function Dinesh Excel Worksheet Functions 3 March 18th 09 02:26 AM
Modify range variable passed through Function spyd3r Excel Programming 8 February 14th 06 11:22 PM
How a function can modify a value from some cells ? Cristian Excel Programming 5 January 3rd 06 08:10 PM
Can I modify a Hyperlink with a function? barrfly Excel Discussion (Misc queries) 7 June 2nd 05 12:03 AM


All times are GMT +1. The time now is 11:59 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"