+ Reply to Thread
Results 1 to 3 of 3

copy paste from worksheet to other worksheet from cell B1 to cell A1

  1. #1
    Registered User
    Join Date
    06-03-2013
    Location
    brussels
    MS-Off Ver
    Excel 2007
    Posts
    94

    copy paste from worksheet to other worksheet from cell B1 to cell A1

    All,

    Could someone please help?

    I have a code that copies the worksheet from one workbook and paste it into a new workbook.
    However in the input worksheet the text starts at B1, so I would like to copy the entire sheet to start at A1.

    Here's what I have so far:


    For Each sheetje In ImportWB.Sheets
    'Debug.Print sheetje.Name
    'Debug.Print sheetje.UsedRange.Address

    'Find "Virtual" or "DO_" on the sheet
    Set findRNG = sheetje.Range("B1").Find(What:="Virtual")
    'Search next value
    Set findRNG2 = sheetje.Range("B3").Find(What:="DO_")

    If (Not findRNG Is Nothing Or Not findRNG2 Is Nothing) Then

    sheetje.Copy After:=NewWorkbook.Sheets(1)



    'reset RNG
    Set findRNG = Nothing
    Set findRNG2 = Nothing
    Else
    'Nothing found
    End If


    Next


    Thanks a bunch

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: copy paste from worksheet to other worksheet from cell B1 to cell A1

    Please use code tags with your code.

    Please Login or Register  to view this content.
    why can not you change B1 to A1?

  3. #3
    Registered User
    Join Date
    06-03-2013
    Location
    brussels
    MS-Off Ver
    Excel 2007
    Posts
    94

    Re: copy paste from worksheet to other worksheet from cell B1 to cell A1

    in the input I have to find for value B1 for a particular value, If found, he needs to copy paste the entire sheet to A1. Not B1.

    I have found a solution , maybe not the most proper one but it works fine :

    After the copy I just delete column A

    'STEP 8: Loop through the whole discovery report and check for sheets with the value like "%Virtual%" or "DO_%"
    For Each sheetje In ImportWB.Sheets
    'Debug.Print sheetje.Name
    'Debug.Print sheetje.UsedRange.Address

    'Find "Column number" on the sheet
    Set findRNG = sheetje.Range("B1").Find(What:="Virtual")
    'Search next value
    Set findRNG2 = sheetje.Range("B3").Find(What:="DO_")

    If (Not findRNG Is Nothing Or Not findRNG2 Is Nothing) Then

    'Delete column A after loop
    sheetje.Copy After:=NewWorkbook.Sheets(1)
    Columns("A:A").Select
    Selection.Delete Shift:=xlToLeft


    'reset RNG
    Set findRNG = Nothing
    Set findRNG2 = Nothing
    Else
    'Nothing found
    End If


    Next

+ 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