+ Reply to Thread
Results 1 to 7 of 7

find and paste

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-15-2004
    Posts
    246

    find and paste

    hi im needing some help. I want some VB code to copy range B2:F2 and searching from B6 down paste it in the first blank cell.

  2. #2
    Registered User
    Join Date
    07-25-2005
    Posts
    62
    Dim iIndex as Integer

    Index = 6

    Do While Not Cells(iIndex, 2) = Empty

    iIndex = iIndex +1

    Loop

    'when the loop exits Cells(iIndex, 2) will refer to the first blank cell

  3. #3
    Forum Contributor
    Join Date
    06-15-2004
    Posts
    246

    help

    thank you for your reply. m getting debug error on the following line

    Do While Not Cells(iIndex, 2) = Empty

  4. #4
    Registered User
    Join Date
    07-25-2005
    Posts
    62
    Oops, if you copy-pasted my code change line

    Index = 6

    to

    iIndex = 6

    Sorry about that. You're getting the error because iIndex was never set to anything in my errored code.

  5. #5
    Forum Contributor
    Join Date
    06-15-2004
    Posts
    246

    help

    im having a little diff still
    ive tried to mod your code to this


    Range("B2:F2").Copy

    Dim iIndex As Integer

    iIndex = 6

    Do While Not Cells(iIndex, 2) = Empty



    iIndex = iIndex + 1

    Loop
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False


    im not getting any joy though, do you know why its not working

  6. #6
    Registered User
    Join Date
    07-25-2005
    Posts
    62
    after the loop exits add

    Cells(iIndex,2).select

    or change

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    to

    Cells(iIndex,2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

+ 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