+ Reply to Thread
Results 1 to 31 of 31

Microsoft Recorder Needs to go on a Diet!

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Microsoft Recorder Needs to go on a Diet!

    I have been attempting to get code to copy and paste cells, then move them to another sheet, and delete the original file that was copied.

    I did this through Record Macro, and I want to cry...

    If Microsoft thought about anything they didn't think about how to record macros in their own language. There is so much fat in it that I am having a hard time to figure it out what is actually needed.

    Here is the code.

    Option Explicit
    
    Sub Test()
    '
    ' Test Macro
    '
    
    '
        Selection.Copy
        ActiveCell.Offset(46, 39).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-43, -39).Range("A1:K1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(43, 40).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-40, -40).Range("A1:K1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(40, 41).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-37, -41).Range("A1:K1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(37, 42).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-34, -42).Range("A1:K5").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(34, 43).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-46, -28).Range("A1:K1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(46, 29).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-43, -29).Range("A1:K1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(43, 30).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-40, -30).Range("A1:K1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(40, 31).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-37, -31).Range("A1:K1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(37, 32).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-32, -31).Range("A1:B1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(32, 32).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-34, -28).Range("A1:F1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(34, 29).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-32, -29).Range("A1:F1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(32, 30).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-30, -30).Range("A1:F1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(30, 31).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-25, -51).Range("A1:Z3").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(25, 52).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-21, -52).Range("A1:Z3").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(21, 53).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-17, -53).Range("A1:Z3").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(17, 54).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-13, -54).Range("A1:Z3").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(13, 55).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-8, -53).Range("A1:D1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(8, 54).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-8, -46).Range("A1:E1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(8, 47).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(-8, -37).Range("A1:E1").Select
        Application.CutCopyMode = False
        Selection.Copy
        ActiveCell.Offset(8, 38).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveCell.Offset(0, -19).Range("A1:T1").Select
        Application.CutCopyMode = False
        Selection.Cut
        Application.CutCopyMode = False
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
        End With
        Selection.Cut
        Sheets("NCMR Data").Select
        ActiveCell.Offset(-7, -2).Range("A1").Select
        ActiveSheet.Paste
        ActiveCell.Offset(-2, 20).Range("A1").Select
        Selection.Copy
        ActiveCell.Offset(2, -21).Range("A1").Select
        ActiveSheet.Paste
    End Sub
    Ultimately I will be wanting the pasting to be done via the last row, but for now this will work... if I can figure out what in god's green earth Microsoft actually put together for me...

    Can someone shed some light on what is going on? I'm about to re-write this code to actually make sense to a human being...

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

    actually for the macro recorder that's pretty good. no scrolling and so on. it basically just recorded exactly what you did as you did it. do you have a specific issue?

  3. #3
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by JosephP View Post
    actually for the macro recorder that's pretty good. no scrolling and so on. it basically just recorded exactly what you did as you did it. do you have a specific issue?
    The reason there is no scrolling is because I have everything viewed at 50% actual size so everything works as it is meant to.

    Actually yes. I the cells are grouped, I need to only the first cell copied, then pasted, then continue down the path till it's all in a single row, then that is copied over to another sheet, and a numeric ID is given to said row.

    The cells in question are B11, B14, B17, B20, B23, Q11, Q14, Q17, Q20, Q25, V23, V25, V27, B32, B36, B40, B44, B49, L49, V49.

    They have to be in that order because this is part of a form, which will be pasted into a row, which will then be moved to a database style sheet, with a identifier at the beginning of said row. This row though will have to be at the end of all data.

    So as you can see the program did what it was meant to, but it never would work the way that it needs to.
    Last edited by Cyberpawz; 04-19-2012 at 10:52 AM.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by Cyberpawz View Post
    So as you can see the program did what it was meant to, but it never would work the way that it needs to.
    that sounds like you're blaming the recorder for doing what it was meant to instead of something else that you hoped it might magically do. I don't see the connection to dieting.

  5. #5
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by JosephP View Post
    that sounds like you're blaming the recorder for doing what it was meant to instead of something else that you hoped it might magically do. I don't see the connection to dieting.
    Selection.Copy
        ActiveCell.Offset(46, 39).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    You are telling me you couldn't write a better line of code to do the same thing?

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by Cyberpawz View Post
    Selection.Copy
        ActiveCell.Offset(46, 39).Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    You are telling me you couldn't write a better line of code to do the same thing?
    I'm pretty sure I didn't tell you that but that's not the point. I know what the purpose is, the recorder doesn't. you're basically blaming a cassette recorder for recording you going "erm" instead of just playing the Gettysburg address like you meant.

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Microsoft Recorder Needs to go on a Diet!

    I would suggest re-recording your steps but stop and start the recorder after each copy/paste. That way, you can skip a lot of the offsets (I think) as well as any selections you make by mistake. Doing so will make analysing your code much easier to do by you or anyone else.

    The macro recorder works really well imo but as JosephP stated, it will record almost every click and action you make.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Microsoft Recorder Needs to go on a Diet!

    Perhaps if you upload a mock workbook with mock data (nothing personal or sensitive) then maybe someone can write better code.

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Microsoft Recorder Needs to go on a Diet!

    The macro recoder does excatly as it is designed to do - record your actions into VBA code. It's up to you to streamline the code. I would only use the recorder to get correct syntax, but it was designed to help novice users.
    Hope that helps.

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

    Free DataBaseForm example

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

    It records what you do. You select a cell, it records that. You scroll, it records that. It has no way of knowing what your ultimate purpose is so it simply records every step you take. The fact that you have it set to record relative references makes it a little more convoluted than need be but it ain't that bad really. obviously you disagree.

  11. #11
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Microsoft Recorder Needs to go on a Diet!

    How is a recorder, which is meant to record your actions, know what you would consider to be fluff? If it wasn't for the macro recorder and this site (and other sites that I am not aloud to mention), I would still be useless regarding vba. Your code is understandable but you have recorded a lot of steps, which makes it troublesome to look at. Like I suggested in post #3, re-record smaller amounts of actions and you will have an easier time understanding what is going on. Imo, you have recorded so much at one time that even my eyes want to glaze over the procedure.

  12. #12
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by Mordred View Post
    How is a recorder, which is meant to record your actions, know what you would consider to be fluff? If it wasn't for the macro recorder and this site (and other sites that I am not aloud to mention), I would still be useless regarding vba. Your code is understandable but you have recorded a lot of steps, which makes it troublesome to look at. Like I suggested in post #3, re-record smaller amounts of actions and you will have an easier time understanding what is going on. Imo, you have recorded so much at one time that even my eyes want to glaze over the procedure.
    I did, and it still leaves a lot to like... Here is the code:

    
    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        Range("B11:L11").Select
        Selection.Copy
        Range("AO57").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    End Sub
    All I want to do is to copy a cell, and paste into a cell, but instead of copy and pasting the formula, I want to copy and paste the result.

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Microsoft Recorder Needs to go on a Diet!

    IMO, the macro recorder is a godsend for people new to VBA -- it helps them learn Excel's enormous object model. It's far from perfect in divining users intent, but great for its own intent. I still use it from time to time rather than muddling through Help.

    In addition, once you learn how, cleaning up the code it generates is itself an exercise in reinforcing efficient programming.
    Entia non sunt multiplicanda sine necessitate

  14. #14
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
        Range("B11:L11").Copy
        Range("AO57").PasteSpecial Paste:=xlPasteValues
    End Sub
    you can also just assign values from range to range if you resize the target to match the source.
    Last edited by JosephP; 04-19-2012 at 01:14 PM.

  15. #15
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Microsoft Recorder Needs to go on a Diet!

    ...Continuing from above, it could look something like this:

    Sub RngToRngValueExample()
    
    Dim rngSource As Range
    Dim lngColCount As Long
    
       Set rngSource = Range("B11:L11")
       lngColCount = rngSource.Columns.Count
    
       Range("AO57").Resize(1, lngColCount).Value = rngSource.Value
    
    End Sub
    No copying, no pasting...
    Last edited by AlvaroSiza; 04-19-2012 at 01:51 PM. Reason: Oops...Thx J
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  16. #16
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by AlvaroSiza View Post
    ...Continuing from above, it could look something like this:

    Sub RngToRngValueExample()
    
    Dim rngSource As Range
    Dim lngColCount As Long
    
       Set rngSource = Range("B11:L11")
       lngColCount = rngSource.Columns.Count
    
       Range("AO57").Resize(1, lngColCount).Value = rngSource.Value
    
    End Sub
    No copying, no pasting...
    Ok, but the point is that I want B11 to be the only thing copied over, Or is that what the re size does is take out all the other fields so it only copies over a single cell instead of multiple?

  17. #17
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

    you don't wanna use 0 in a resize call. :-)

  18. #18
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

        Range("AO57").value = range("b11").value

  19. #19
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by JosephP View Post
        Range("AO57").value = range("b11").value
    I figured that, but the question comes two fold, 1 can I have it choose multiple cells that don't coincide? and the resize part, this makes it so it pastes only one cell not multiple correct?

  20. #20
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by Cyberpawz View Post
    ...and the resize part, this makes it so it pastes only one cell not multiple correct?
    Incorrect. In your original syntax (which you have since rebutted as being incorrect because you only wanted one cell, not a range), you provided a range extending 11 columns within Row 11 ("B11:L11"). You also provided a single cell location for where you wanted the data to go ("AO57"). Joseph was pointing out to you that under a .value = .value approach, it is necessary to Resize (by using the Resize property) your destination range be the same size as your source range. Otherwise, you will error out.

    Quickie on resize...

    Assume you select Range("A1"). Now assume that you want everything 2 rows to the right, or the ultimate range of Range("A1:C1"). The Resize property allows you resize a base range to whatever dimensions you choose. Thus, the example above would be expressed as:

    Range("A1").Resize(1, 3)
    I think you are learning a few things from this thread beyond just the syntax.

    1. People are here to help as long as you will help yourself. Provide as much detail as possible. Provide a sample workbook when possible.
    2. You need to do some research. It is not our job to help you, we do so because we learned (and are learning) here and want to give back. Your original tone was not conducive to a constructive thread (Excel was broke before you ever posted).

  21. #21
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by AlvaroSiza View Post
    Incorrect. In your original syntax (which you have since rebutted as being incorrect because you only wanted one cell, not a range), you provided a range extending 11 columns within Row 11 ("B11:L11"). You also provided a single cell location for where you wanted the data to go ("AO57"). Joseph was pointing out to you that under a .value = .value approach, it is necessary to Resize (by using the Resize property) your destination range be the same size as your source range. Otherwise, you will error out.

    Quickie on resize...

    Assume you select Range("A1"). Now assume that you want everything 2 rows to the right, or the ultimate range of Range("A1:C1"). The Resize property allows you resize a base range to whatever dimensions you choose. Thus, the example above would be expressed as:

    Range("A1").Resize(1, 3)
    I think you are learning a few things from this thread beyond just the syntax.

    1. People are here to help as long as you will help yourself. Provide as much detail as possible. Provide a sample workbook when possible.
    2. You need to do some research. It is not our job to help you, we do so because we learned (and are learning) here and want to give back. Your original tone was not conducive to a constructive thread (Excel was broke before you ever posted).
    I didn't say Excel was broken, I said the Microsoft's attempt at automated script design is broken... big difference.

  22. #22
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by Cyberpawz View Post
    I didn't say Excel was broken, I said the Microsoft's attempt at automated script design is broken... big difference.
    I will buy you a beer if you can provide a few bullet points of items you think should be different about it that can withstand rebuttal. As everyone else has stated, there is a reason it is the way it is, you just happen to not like it, which is unfortunate.

    That said, here is a script to accomplish what, as far as I can tell, you are after. I was not clear on your A(n) & V2 numbering system. This code copies the fields of the form (which are co-located in a horizontal and contiguous range below the form; Range("E101:X101") to the next available row within the Data worksheet.

    Option Explicit
    
    Sub SendtoData()
    
    Dim ws1 As Worksheet, ws2 As Worksheet
    Dim rngSource As Range, rngDestAnchor As Range, rngDest As Range
    
       With Application
          .ScreenUpdating = False
          .EnableEvents = False
       End With
    
          Set ws1 = ActiveWorkbook.Sheets("Internal NCMR")
          Set ws2 = ActiveWorkbook.Sheets("NCMR Data")
          Set rngSource = ws1.Range("E101:X101")
          Set rngDestAnchor = ws2.Range("B20000").End(xlUp).Offset(1, 0)
          Set rngDest = rngDestAnchor.Resize(1, 20)
          
          rngDest.Value = rngSource.Value
    
       With Application
          .EnableEvents = True
          .ScreenUpdating = True
       End With
    
    End Sub
    Last edited by AlvaroSiza; 04-19-2012 at 04:29 PM.

  23. #23
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Microsoft Recorder Needs to go on a Diet!

    If you are only assigning to one cell, there is no need to resize. if you want to do several discontiguous cells you'll need a loop. where are the cell values supposed to go?

  24. #24
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Quote Originally Posted by JosephP View Post
    If you are only assigning to one cell, there is no need to resize. if you want to do several discontiguous cells you'll need a loop. where are the cell values supposed to go?
    Ok, here is the document. Or an example of one, this is old data so it's not up to date, nor is it relevant.

    In any case If you go to the Internal NCMR, you'll see the JOB# box, it is a pull down menu. Select a job number, from there you will see fields self populate.

    Fill in the document, gibberish if you will, the Added By is a pull down menu.

    From there, I want all these fields to go into NCMR Data.

    If you look at NCMR data, there is a number at the beginning, there is also one at the end on V2. It is an attempt to create a ID system for the list. The concept is that when the script is run, it will copy V2 to the last row and paste it into A#, from there it will copy all the fields in Internal NCMR and paste them in their corresponding columns. Originally I had it where it would paste into a row under the NCMR and then select, delete, and paste into the last row of NCMR Data, but I never got past the point of delete and paste.

    If this make any sense to you, I'd appreciate some help.
    Attached Files Attached Files

  25. #25
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Microsoft Recorder Needs to go on a Diet!

    Well here is the code after spending a day working on it, and getting a little help, I came up with this.

    Sub CopyValues()
        'Internal NCMR
        Dim wsInt As Worksheet
        
        'Copy Ranges
        Dim c As Variant
    
        'Paste Ranges
        Dim p As Variant
        
        'Setting Sheet
        Set wsInt = Sheets("Internal NCMR")
        
        c = Array(Range("B11"), Range("B14"), Range("B17"), Range("B20"), Range("B23"), Range("Q11") _
                    , Range("Q14"), Range("Q17"), Range("Q20"), Range("R25"), Range("V23"), Range("V25") _
                    , Range("V27"), Range("B32"), Range("B36"), Range("B40"), Range("B44"), Range("D49") _
                    , Range("L49"), Range("V49"))
    
        p = c
    End Sub
    I will still say the recorder needs to go on a diet... from what I needed to what it did were two entirely different things.
    Last edited by Cyberpawz; 04-23-2012 at 08:18 AM.

+ 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