Results 1 to 5 of 5
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Selected Range (2002)

    You can actually use the keyword Selection in VBA (it usually represents a range, but it could be a chart or a shape too). So you could use

    Dim oCell As Range
    For Each oCell In Selection.Cells
    ...
    Next oCell

  2. #2
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selected Range (2002)

    Thanks Hans, This is similar (in some way's) to some code you previosly assisted me with, I will attempt to adapt.

  3. #3
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selected Range (2002)

    Can a "selected range" be used within code? I am trying to:

    wb1 - source - with a selected range of say C2:C50 - this would be the active book upon start - variable
    wb2 - destination - constant > named 0808.

    wb2 - ensure filter reset
    Loop through wb1 selection, find in wb2 column C, If wb2 column J is blank, copy from wb1 col J, if not show messagebox, after messagebox resume loop.

    So if C matches C, copy from J to J, unless wb2 J is not blank, th4 show message, then resume.

  4. #4
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selected Range (2002)

    Sorry, I'm struggling with this.

    Sub Update_0808()

    Dim oCell As Range
    Dim ws2 As Worksheet
    Dim m2 As Long
    Dim rng2 As Range

    Dim rngFound As Range
    Dim c As Integer

    Set ws2 = Worksheets("0808")

    m2 = ws2.Cells(ws2.Rows.Count, 3).End(xlUp).Row '0808 final row number

    Set rng2 = ws2.Range("C2:C" & m2) '0808 C Range


    For Each oCell In Selection.Cells

    Next oCell

    End Sub

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Selected Range (2002)

    <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29> You'll have to put some instructions between For ... and Next ..., otherwise the code won't do anything. What do you want to accomplish (I have no idea what your edited first post means)?

Posting Permissions

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