+ Reply to Thread
Results 1 to 2 of 2

Can this small bit of code be combined to one line of code?

  1. #1
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Can this small bit of code be combined to one line of code?

    Please Login or Register  to view this content.
    I have toyed with this, but I couldn't find a simpler way to write it. Not that it is complex, but I am learning VBA and I want to write code as efficiently as possible. Can any of this be condensed or combined?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Can this small bit of code be combined to one line of code?

    Hi Wedge120,

    I have two workbooks open and have two methods to do what you ask. The syntax is the hard part. What VBA wants is always a trial and error event for me.

    I'm taking the stuff on Row 4 on Sheet1 of Workbook 2 and copying it to Workbook1 Sheet1 Row 9.
    The first way is to use the Copy ....:=Destination method and it looks like:
    Please Login or Register  to view this content.
    A second way is to simply copy over the stuff on the left hand side of the equation with the stuff from the right side of the equations. It looks like this:
    Please Login or Register  to view this content.
    Note I had to put .Value after the Rows - I'm not positive why but trial and errored it to work.
    In your example above I think I'm close to suggest
    Please Login or Register  to view this content.
    If you have already selected what you want to copy then Selection.copy should work.
    I'm not sure you can use the workbook name of "workbook" as it might be a reserved word. Also you need to be specific about which worksheet in the workbook your are going to copy onto.

    hope that helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

+ 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