+ Reply to Thread
Results 1 to 5 of 5

.Offset, .Range and .Cells problem in VBA

  1. #1
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    .Offset, .Range and .Cells problem in VBA

    Hi

    I have a code which, just before closing a workbook (wbFrom), exports data to a closed workbook (wbTo) and then closes both workbooks. My problem is the use of syntax to export data. In the following code, the rem'd out code works but not the non rem'd out code. Any suggestions of what could be going wrong here?

    Please Login or Register  to view this content.

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

    Errors? Wrong data exported? Data exported to wrong place?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: .Offset, .Range and .Cells problem in VBA

    Hi Norie

    I should have made it clear! The problem is that with the rem'd out code, the information is correctly transfered to the file named MasterFile whilst the code that is not rem'd out does to transfer the data. I would have thought it should.

    I have upto 24 columns of info to transfer (in the code I have only done 4, A to D) and could be many rows. I don't want to write 24 times .Offset(,5)=wbFrom etc., hence the use of i and t counters.

    Sorry, I should have added that when I left out the .Value, it gave an object not defined error
    Last edited by newbi004; 04-30-2013 at 05:59 AM. Reason: additional info

  4. #4
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: .Offset, .Range and .Cells problem in VBA

    Any thoughts?

  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: .Offset, .Range and .Cells problem in VBA

    So this code works, but you don't want to repeat it for all columns/rows
    Please Login or Register  to view this content.
    Can I ask why you are doing this cell by cell?

    Couldn't you copy the whole columns/range?

    Something like this perhaps, which is partly a guess as it's not 100% clear what columns you are copying.
    Please Login or Register  to view this content.

+ 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