+ Reply to Thread
Results 1 to 3 of 3

don't replace VBA code

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2008
    Posts
    1

    don't replace VBA code

    Hi, i have the following code:

    Sub Macro4()
    '
    ' Macro4 Macro
    ' Macro recorded 2008-05-13 by Test
    '
    
        Selection.Copy
        Sheets("Blad3").Select
        Range("A8").Select
        ActiveSheet.Paste
        Sheets("Blad2").Select
        Range("G10").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Blad3").Select
        Range("A8").Select
        ActiveSheet.Paste
        Sheets("Blad2").Select
        Range("G11").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Blad3").Select
        Range("B8").Select
        ActiveSheet.Paste
        Sheets("Blad2").Select
        Range("G12").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Blad3").Select
        Range("C8").Select
        ActiveSheet.Paste
        Sheets("Blad2").Select
        Range("G13").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Blad3").Select
        Range("D8").Select
        ActiveSheet.Paste
        Sheets("Blad2").Select
        Range("G14").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Blad3").Select
        Range("E8").Select
        ActiveSheet.Paste
        Sheets("Blad2").Select
        Range("G15").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Blad3").Select
        Range("F8").Select
        ActiveSheet.Paste
        Sheets("Blad2").Select
        Range("G16").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Blad3").Select
        Range("G8").Select
        ActiveSheet.Paste
        Range("H8").Select
        Application.CutCopyMode = False
        ActiveCell.FormulaR1C1 = "=Blad2!R[10]C[-1]"
        Selection.Font.Bold = False
        Range("I8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[12]C[-2]"
        Selection.Font.Bold = False
        Range("J8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[14]C[-3]"
        Selection.Font.Bold = False
        Range("K8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[16]C[-4]"
        Selection.Font.Bold = False
        Range("L8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[18]C[-5]"
        Selection.Font.Bold = False
        Range("M8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[20]C[-6]"
        Selection.Font.Bold = False
        Range("N8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[22]C[-7]"
        Selection.Font.Bold = False
        Range("O8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[24]C[-8]"
        Selection.Font.Bold = False
        Range("P8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[26]C[-9]"
        Selection.Font.Bold = False
        Range("Q8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[28]C[-10]"
        Selection.Font.Bold = False
        Range("R8").Select
        ActiveCell.FormulaR1C1 = "=Blad2!R[30]C[-9]"
        Selection.Font.Bold = False
        Range("S8").Select
        ActiveWindow.ScrollColumn = 7
        ActiveWindow.ScrollColumn = 6
        ActiveWindow.ScrollColumn = 5
        ActiveWindow.ScrollColumn = 4
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 1
        Rows("8:8").Select
        Selection.Insert Shift:=xlDown
        Sheets("Blad4").Select
    End Sub
    This code moves some information from sheet2 to sheet3. And then makes a break, so other members also can create their own member.

    But my problem is, when one member registrates. The other gets HIS information in their fields. How do i avoid this?

    I think this is because of the formula i'm using on sheet2, that i later on move
    that formula to sheet3. Because then it's the same and everyone gets that info.

    This is one of the formula that is moved: =Sheet2!G18

    So how do i avoid this, and is there a smart method to avoid that other members ar affected by anothers information and that they do not have to get his/her info in their fields.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your code needs some serious tidying up. Try amending your code like this for a more efficient way

    Selection.Copy   Sheets("Blad3").Range("A8")
    Sheets("Blad3"). Range("A8")=    Sheets("Blad2").Range("G10")
    'etc
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    I agree with Roy 100%

    The macro recorder is a great tool if you need to remember how to do something you have forgotten (ie, how to color a cell, how to delete a row). It is VERY inefficient for creating a functional VBA driven spreadsheet. I suggest looking into some VBA tutorials and chopping that down a bit, then asking more specific questions.

    Another option is to post a .zip copy of the workbook you are working with. Provide some specific instructions and someone will likely be able to piece together some code for you.

+ 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