Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Put data in cells
I have a vba function as follows:
Function zputData() Dim cell As Range Set Range1 = ActiveSheet.Range("a1:a7") For Each cell In Range1.Cells cell.Value = "abc" Next End Function If i put =zputData() in A10 I get a #VALUE! and do not get abc in cells a1 to a7. If i execute abc= zputData() in the immediate window, a1 to a7 gets set. What am I doing wrong? Thanks, Fred |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Put data in cells
Fred,
A function called from within a worksheet can only return a result, it cannot change the attributes of cells, especially other cells. You can't do what you are trying to do. The best you could do would be to have event code that does it based upon a condition. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "fredz" wrote in message ... I have a vba function as follows: Function zputData() Dim cell As Range Set Range1 = ActiveSheet.Range("a1:a7") For Each cell In Range1.Cells cell.Value = "abc" Next End Function If i put =zputData() in A10 I get a #VALUE! and do not get abc in cells a1 to a7. If i execute abc= zputData() in the immediate window, a1 to a7 gets set. What am I doing wrong? Thanks, Fred |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
compare 2 column cells and return the adjacent columns cells data of the cell | Excel Worksheet Functions | |||
join data in multiple cells when adjoining cells match criteria ?? | Excel Worksheet Functions | |||
Need to average data if in cells, but ignore blank cells. | Excel Worksheet Functions | |||
Returning data of multiple cells for lookup of mulltiple cells | Excel Discussion (Misc queries) | |||
trying to create an (almost) circular formula between cells and data validated cells with lists | Excel Worksheet Functions |