Results 1 to 8 of 8

Thread: Easy Excel Macro Question

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Colorado
    Posts
    39

    Talking


    I don't have the help file on my machine, and it's been awhile since I've done this. How do I set the range property?

    For example

    Dim MyRange as Range

    MyRange = Activecell.range

    This doesn't work because it wants more parameters for the range property.

    I also tried Range(activecell), but that didn't work either.

    Thanks,

    LauRa
    LauRa
    "Work like you don't need the money...Love like you've never been hurt...Dance like nobody is watching..."

  2. #2
    Hyperactive Member compuGEEK's Avatar
    Join Date
    May 1999
    Location
    Mpls,MN,USA
    Posts
    281
    Hi,

    You could try, MyRange = ActiveWindow.Selection

    Hope this helps!

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Colorado
    Posts
    39
    That didn't work, but thanks anyway. It appears that the selection property actually takes the value of the cell instead of the range.

    LauRa
    LauRa
    "Work like you don't need the money...Love like you've never been hurt...Dance like nobody is watching..."

  4. #4
    Hyperactive Member barrk's Avatar
    Join Date
    Sep 2000
    Location
    My own little world
    Posts
    274
    Try something like this:

    MyRange = range("A1:C1")




  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Colorado
    Posts
    39
    I need it to be a little more general.
    LauRa
    "Work like you don't need the money...Love like you've never been hurt...Dance like nobody is watching..."

  6. #6
    Hyperactive Member barrk's Avatar
    Join Date
    Sep 2000
    Location
    My own little world
    Posts
    274
    You can pass variable to the range something like this:
    dim myvar as variant

    myvar = activecell.formulaR1C1
    MyRange = range(myvar)






  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Colorado
    Posts
    39

    I keep getting an error "Object variable or With block variable not set". Should I be more flexible with my variable definitions?

    Sub Test()
    Dim myRange As Range
    Dim urRange As Range
    Range("A2").Select
    myRange.FormulaR1C1 = ActiveCell.FormulaR1C1
    urRange = Range("myrange")

    End Sub

    LauRa
    LauRa
    "Work like you don't need the money...Love like you've never been hurt...Dance like nobody is watching..."

  8. #8

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    Colorado
    Posts
    39
    Thanks for the help. I finally got it to work. Here's the code in case anyone's interested:

    MFCount & SFCount are Integers set earlier in the code

    If SFUPC = MFUPC Then
    Windows("Final_Multi_Family.xls").Activate
    tempRange = "I" & MFCount
    Range(tempRange).Activate
    Desc = ActiveCell.Offset(0, 1).Text
    Windows("Final_SingleFamily.xls").Activate
    tempRange = "J" & SFCount
    Range(tempRange).Activate
    ActiveCell.Value = Desc

    ElseIf SFUPC < MFUPC Then

    Else
    End If
    LauRa
    "Work like you don't need the money...Love like you've never been hurt...Dance like nobody is watching..."

Posting Permissions

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



Click Here to Expand Forum to Full Width