Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

How to write to multiple cells from a single function call

$
0
0
Currently my UDF WName()outputs a result in each spreadsheet cell that it was called from.

Now I am focused on developing the last few lines in order to output a second variable ("MinDist") four cells to the right of each UDF call in the spreadsheet.
I'm trying to do this via ActiveCell.Offset., but not getting the result I need. Here's a snipit:
Code:

    WName = MKRTable(MinIndex, WMKR)
   
    'Nice to have: Output the MinDist value four columns to the right of the WName function call.  Need ActiveCell.Select?
    ActiveCell.Offset(0, 4).Range("A1").Select              'This doesn't work
    ActiveCell.Offset(0, 4).Range("A1").Value = MinDist    'This doesn't work
    ActiveCell.Offset(0, -4).Range("A1").Select            'This doesn't work

Full spreadsheet and VBA code attached.

Note that for debugging, I'm just looking now at sheet "A", cell "A14"

Any suggestions?

Thanks!
g
Attached Files

Viewing all articles
Browse latest Browse all 50061

Trending Articles