+ Reply to Thread
Results 1 to 5 of 5

for each cell in range in wb1 manipulate string & paste to wb2 diff col same row

  1. #1
    Registered User
    Join Date
    02-06-2013
    Location
    Coventry, Enland
    MS-Off Ver
    Excel 2003
    Posts
    3

    for each cell in range in wb1 manipulate string & paste to wb2 diff col same row

    For Each cell In myrange.SpecialCells(xlCellTypeConstants)
    thisrow = cell.Row
    dbstr = left(cell,2) ' paste to wb2 col 'a' row thisrow
    newstr =mid(cell, 3,6) & "/" & right(cell,2) ' paste to wb2 col 'h' row thisrow

    next cell


    this is example of what I thought by using loop.

    will also be taking other ranges and copying complete to other workbook no cell manipulation required

    any help or suggestions

    regards Alan

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: for each cell in range in wb1 manipulate string & paste to wb2 diff col same row

    Alan

    One of the main things you need to add are workbook and worksheet references in the code to make sure the correct data and destination are being used.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-06-2013
    Location
    Coventry, Enland
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: for each cell in range in wb1 manipulate string & paste to wb2 diff col same row

    Quote Originally Posted by Norie View Post
    Alan

    One of the main things you need to add are workbook and worksheet references in the code to make sure the correct data and destination are being used.
    Thank you Norie I do appreciate that, my problem was how to move between workbooks to do the pasting whilst in the for loop

    or do I just actiavte workbook2 select the cell required and then set cell.Value to be that of string value in workbook1 example dbstr then close workbook2 (assuming I will be back in workbook1 inside for loop.

  4. #4
    Registered User
    Join Date
    02-06-2013
    Location
    Coventry, Enland
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: for each cell in range in wb1 manipulate string & paste to wb2 diff col same row

    I supposed I should have posted the following:-

    DownloadWB = Application.GetOpenFilename( _
    FileFilter:="Microsoft Excel Workbooks, *.xls; *.xlsx", Title:="Open Workbook")

    Workbooks.Open DownloadWB

    Set download = ActiveWorkbook
    download.Activate

    Range(Cells(1, 1), Cells(myLastRow, 1)).Select
    Set myrange = ActiveSheet.Range(ActiveWindow.Selection.Address)

    For Each cell In myrange.SpecialCells(xlCellTypeConstants)
    ThisRow = cell.Row
    dbstr = Left(cell, 2) ' paste to wb2 col 'a' row thisrow
    newstr = Mid(cell, 3, 6) & "/" & Right(cell, 2) ' paste to wb2 col 'h' row thisrow

    Next cell

    as you can gather workbook1 is download

    I also do something similar for workbook2 which is named databook

    hope this helps still new to this

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: for each cell in range in wb1 manipulate string & paste to wb2 diff col same row

    If you correctly reference everything you don't need to move between workbooks.

+ 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