Closed Thread
Results 1 to 3 of 3

help with macro

  1. #1
    Registered User
    Join Date
    10-08-2010
    Location
    Oxford, UK
    MS-Off Ver
    Excel 2003
    Posts
    5

    help with macro

    Good Afternoon all,

    I am quite new to macro's, but am trying to do a simple task of adding cells from 2 different worksheets into a third.

    So I want Cell B3 of sheet1 added to Cell B4 of Sheet2 and the total to appear in Cell B3 of Sheet 3.

    The code I have got to work is:

    Sub count()

    myvalue = Sheets("SHEET1").Range("B3") + Sheets("SHEET2").Range("B4")
    Sheets("SHEET3").Range("B3").Value = myvalue

    End Sub

    This works, but I need to get this method to work for all cells in a range (add each cell from Sheet1 from B4 to U46 inclusive, and Sheet2 B3 to U45 inclusive, to appear in sheet 3 in the range of B4 to U46).

    Is it possible to do this by a simple peive of code? or will I have to enter each calculation seperately like:

    Sub count()

    myvalue = Sheets("SHEET1").Range("B3") + Sheets("SHEET2").Range("B4")
    Sheets("SHEET3").Range("B3").Value = myvalue
    myvalue = Sheets("SHEET1").Range("B4") + Sheets("SHEET2").Range("B5")
    Sheets("SHEET3").Range("B4").Value = myvalue
    myvalue = Sheets("SHEET1").Range("B5") + Sheets("SHEET2").Range("B6")
    Sheets("SHEET3").Range("B5").Value = myvalue

    [****and so on****]

    End Sub

    this seems to work but would take me ages to input all the different cell calculations.

    Any advice would be warmly received.

    Ian.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: help with macro

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: help with macro

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST

Closed 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