+ Reply to Thread
Results 1 to 5 of 5

Should I loop this code or can I change range?

  1. #1
    Registered User
    Join Date
    03-24-2014
    Location
    New York
    MS-Off Ver
    Excel 2013
    Posts
    3

    Exclamation Should I loop this code or can I change range?

    I'm currently trying to create a macro that will take updated information in one sheet and automatically update the next sheet. So far I have made it so it will update one cell...how do I make it so it will update all of the cells? Should I run a loop, or is there a way to change the range to include all of the cells? Needless to say, I have zero experience with VBA haha. Below is the code I currently have.

    Private Sub CommandButton1_Click()
    Dim CustomerName As String


    Worksheets("Sheet1").Select
    CustomerName = Range("C4")
    Worksheets("Sheet2").Select
    Worksheets("Sheet2").Range("C4").Select
    ActiveCell.Value = CustomerName
    Worksheets("Sheet1").Select
    Worksheets("Sheet1").Range("C4").Select


    MsgBox "Updated!"
    End Sub

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Should I loop this code or can I change range?

    Please Login or Register  to view this content.

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

    Re: Should I loop this code or can I change range?

    You've only posted code for one cell/value, so it's hard to tell what you are looping or what range you are working with.

    Can you expand on what you want to do?

    By the way, that code can be reduced a wee bit.
    Please Login or Register  to view this content.
    PS Can you add code tags?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    03-24-2014
    Location
    New York
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Should I loop this code or can I change range?

    Thanks for the reduced code! I'll just give the whole story so that I don't miss any points. I am a counselor in a school and have created a Sheet (Sheet1) that shows what classes students have passed/failed/haven't taken. This helps in programming for future semesters. The second sheet contains credit accumulation (So if a student passed they have 1 credit, if failed/need they have 0 credit. This helps show how many credits they have and how much they still need to graduate. Every semester these sheets have to be updated to show the newest grades and credit accumulation. Instead of updating both sheets, I would like to update one and have second sheet automatically update. (If I could format so that P=1 and F=0 automatically on the second sheet as well, that would be cool..). The columns go from A to AZ and there are 385 rows. Let me know if there is any more information I should include.
    Never used a code tag before so I am going to try below now that I have this shortened code.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-24-2014
    Location
    New York
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Should I loop this code or can I change range?

    Alright! I figured out how to update the whole sheet...totally easy with that new code.

    Please Login or Register  to view this content.
    Now I guess my question is how to have the P to transfer as a 1 and F/NE to transfer as 0 on the second sheet.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Trying to Loop This Code for Each Row Within the Range
    By millikim in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-25-2013, 02:48 AM
  2. Can you change the order/pattern that vba uses to loop through a range?
    By Leon V (AW) in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-14-2013, 04:40 AM
  3. Problem using loop for sending excel range in email body using Range to HTML code
    By drajanm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-24-2012, 03:17 AM
  4. Edit code to change variable valuie after each loop.
    By rocksan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2012, 03:07 AM
  5. Code to loop through a column and change cell value based on list
    By davekippen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2011, 04:27 PM

Tags for this Thread

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