Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88087

Select cells from function in VBA

$
0
0

I want to have a macro that first activates a particular worksheet and then selects a particular cell. However, when I run the code below I get the following message:

Run-time error:'1004': Select method of Range class failed.

What am I doing wrong?

Function selectingCells(myWs As String, myCell As Range)

    Sheets(myWs).Activate
    myCell.Select

End Function

Sub callingFunction()

    Call selectingCells("Data", Range("A1"))
    Call selectingCells("Picklist", Range("A1"))

End Sub

Viewing all articles
Browse latest Browse all 88087

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>