+ Reply to Thread
Results 1 to 7 of 7

Revise current macro (SOLVED)

Hybrid View

  1. #1
    Registered User
    Join Date
    04-11-2012
    Location
    Stoke, England
    MS-Off Ver
    Ms 365
    Posts
    68

    Revise current macro (SOLVED)

    Hi All

    Can anyone tell me how to revise this macro to run based on a value entered into sheet "PasteDataHere" Cell T1? It currently works by the entry in red

    Thanks

    Sub Race()
    '
    ' Macro5 Macro
    '
    Application.ScreenUpdating = False
    'Let x = 0
    Do While x < 10
        Sheets("PasteDataHere").Select
        Range("A1:K49").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet3").Select
        Range("A11").Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False
        Sheets("PasteDataHere").Select
        Application.CutCopyMode = False
        Selection.Delete Shift:=xlUp
        Sheets("Sheet3").Select
        Range("M1").Select
        Call GreyCalc
        x = x + 1
    Loop
    End Sub
    Last edited by hazzaska; 12-11-2012 at 02:35 PM. Reason: SOLVED

  2. #2
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Revise current macro

    PHP Code: 
     Dim X As Byte
    Do While 10
        Sheets
    ("PasteDataHere").Select
        Range
    ("A1:K49").Select
        Application
    .CutCopyMode False
        Selection
    .Copy
        Sheets
    ("Sheet3").Select
        Range
    ("A11").Select
        Selection
    .PasteSpecial Paste:=xlPasteValuesAndNumberFormatsOperation:= _
            xlNone
    SkipBlanks:=FalseTranspose:=False
        Sheets
    ("PasteDataHere").Select
        Application
    .CutCopyMode False
        Selection
    .Delete Shift:=xlUp
        Sheets
    ("Sheet3").Select
        Range
    ("M1").Select
        Call GreyCalc
        x 
    1
        
    If >= Sheets("PasteDataHere").[T1].Value Then Exit Do  '<=|'
    Loop 

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Revise current macro

    Hi hazzaska,

    Untested, but see how this goes:

    Sub Race()
    '
    ' Macro5 Macro
    '
    Application.ScreenUpdating = False
    'Let x = 0
    x = Sheets("PasteDataHere").Range("T1").Value
    Do While x < 10
        Sheets("PasteDataHere").Select
        Range("A1:K49").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet3").Select
        Range("A11").Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False
        Sheets("PasteDataHere").Select
        Application.CutCopyMode = False
        Selection.Delete Shift:=xlUp
        Sheets("Sheet3").Select
        Range("M1").Select
        Call GreyCalc
        x = x + 1
    Loop
    End Sub
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Registered User
    Join Date
    04-11-2012
    Location
    Stoke, England
    MS-Off Ver
    Ms 365
    Posts
    68

    Re: Revise current macro

    Hi Thanks for the responses i tailored your solution Trebor76 to this and it works if i manually enter it, can it be done if the value in "paste data here" T1 comes from a formula or even can the macro run until there is no data left in the "paste data here" sheet"

    Heres the one that works if i manually enter a value in T1

    Sub Race()
    '
    ' Macro5 Macro
    '
    Application.ScreenUpdating = False
    'Let x = 0
    Do While X < Sheets("PasteDataHere").Range("T1").Value
        Sheets("PasteDataHere").Select
        Range("A1:K49").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet3").Select
        Range("A11").Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False
        Sheets("PasteDataHere").Select
        Application.CutCopyMode = False
        Selection.Delete Shift:=xlUp
        Sheets("Sheet3").Select
        Range("M1").Select
        Call GreyCalc
        X = X + 1
    Loop
    End Sub
    Thanks again much appreciated.

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Revise current macro

    can it be done if the value in "paste data here" T1 comes from a formula
    Yes, however the value in cell T1 gets there it will work.

  6. #6
    Registered User
    Join Date
    04-11-2012
    Location
    Stoke, England
    MS-Off Ver
    Ms 365
    Posts
    68

    Re: Revise current macro

    Quote Originally Posted by Trebor76 View Post
    Yes, however the value in cell T1 gets there it will work.
    Thanks for your help Trebor76 it works a treat i had to adjust the following in red otherwise it would run the macro half the amount of times

    Cheers

    Sub Race()
    '
    ' Macro5 Macro
    '
    Application.ScreenUpdating = False
    'Let x = 0
    Do While X < Sheets("PasteDataHere").Range("T1").Value
        Sheets("PasteDataHere").Select
        Range("A1:K49").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet3").Select
        Range("A11").Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False
        Sheets("PasteDataHere").Select
        Application.CutCopyMode = False
        Selection.Delete Shift:=xlUp
        Sheets("Sheet3").Select
        Range("M1").Select
        Call GreyCalc
        X = X + 0
    Loop
    End Sub

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Revise current macro (SOLVED)

    Glad it's all sorted

    If you could mark the the thread as solved when you get a moment it would be appreciated.

    Robert

+ 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