+ Reply to Thread
Results 1 to 3 of 3

Excel macro convert to VBA - doesn't work, hangs on Range("Q35").Select

  1. #1
    Harold Good
    Guest

    Excel macro convert to VBA - doesn't work, hangs on Range("Q35").Select

    Hi,

    I created a macro, then later decided to activate it via a ActiveX Option
    Button. As a macro it works fine.

    I copied the macro text into the View Code property of the Option button,
    and when I step through it in VBA it gives a Run time error 1004 when it
    comes to Range("Q35").Select. Interesting because about 10 steps earlier it
    handles Range("N23:N34").Select just fine - if I'm on the correct worksheet
    to begin with. But the Range("Q35") error occurs no matter if I am on the
    correct worksheet.

    Any help would be appreciated.

    Thanks,

    Harold




  2. #2
    Dave Peterson
    Guest

    Re: Excel macro convert to VBA - doesn't work, hangs onRange("Q35").Select

    You can only select a range if it's on the selected worksheet.

    With worksheets("Othersheetnamehere")
    .select
    .range("Q35").select
    end with

    But most of the time, you can work directly against the range and avoid the
    selecting.

    With worksheets("Othersheetnamehere")
    .range("Q35").clearcontents 'say
    end with

    Harold Good wrote:
    >
    > Hi,
    >
    > I created a macro, then later decided to activate it via a ActiveX Option
    > Button. As a macro it works fine.
    >
    > I copied the macro text into the View Code property of the Option button,
    > and when I step through it in VBA it gives a Run time error 1004 when it
    > comes to Range("Q35").Select. Interesting because about 10 steps earlier it
    > handles Range("N23:N34").Select just fine - if I'm on the correct worksheet
    > to begin with. But the Range("Q35") error occurs no matter if I am on the
    > correct worksheet.
    >
    > Any help would be appreciated.
    >
    > Thanks,
    >
    > Harold


    --

    Dave Peterson

  3. #3
    Harold Good
    Guest

    Re: Excel macro convert to VBA - doesn't work, hangs on Range("Q35").Select

    Thanks Dave, I don't know VBA yet, but your suggestion worked!

    Thanks for your help.

    Harold
    ====================
    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > You can only select a range if it's on the selected worksheet.
    >
    > With worksheets("Othersheetnamehere")
    > .select
    > .range("Q35").select
    > end with
    >
    > But most of the time, you can work directly against the range and avoid
    > the
    > selecting.
    >
    > With worksheets("Othersheetnamehere")
    > .range("Q35").clearcontents 'say
    > end with
    >
    > Harold Good wrote:
    >>
    >> Hi,
    >>
    >> I created a macro, then later decided to activate it via a ActiveX Option
    >> Button. As a macro it works fine.
    >>
    >> I copied the macro text into the View Code property of the Option button,
    >> and when I step through it in VBA it gives a Run time error 1004 when it
    >> comes to Range("Q35").Select. Interesting because about 10 steps earlier
    >> it
    >> handles Range("N23:N34").Select just fine - if I'm on the correct
    >> worksheet
    >> to begin with. But the Range("Q35") error occurs no matter if I am on the
    >> correct worksheet.
    >>
    >> Any help would be appreciated.
    >>
    >> Thanks,
    >>
    >> Harold

    >
    > --
    >
    > Dave Peterson




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1