Selecting all data in Excel column regardless of size











up vote
0
down vote

favorite












I have a repetitive process that I must do in Excel for test data collected. I have to do this process for every data point I collect. I collect over 200 data points each test.



My data is auto populated into Columns A and B. I need to be able to select all real data in column A, multiply it by a constant and place in a separate column. The problem is that my data in column A varies in the number of cells for each data point. For example, one set of test data will have 800 rows, then next will have 3200. It is always independent and I need to be able to select the entire row regardless of number of rows.



I need to be able to make this a Macro so I can do all of the other data manipulation necessry at once. The problem lies when I create the macro...I use shortcut to select all data and the Macro sees this step as selecting specified cells. So when I record the Macro for an 3200 cell length data point and then try to run it on a 800 cell data point, it selects 3200 cells. I need it to only select real data.










share|improve this question
























  • Have you tried to just put a formula for a single row, and double-click the auto fill button in the bottom right? (I don't think you need a macro to do this...). If you do want to use VBA however, you can loop through the data until it finds the first blank cell.
    – Breakthrough
    Jun 29 '11 at 12:58












  • @Breakthrough, I thought about looping through too and just found out, that you can ignore one blank cell (if a non blank cell is following) with ActiveSheet.UsedRange.Rows.Count But it depends on what point you want to stop counting.
    – Milde
    Jun 29 '11 at 13:34

















up vote
0
down vote

favorite












I have a repetitive process that I must do in Excel for test data collected. I have to do this process for every data point I collect. I collect over 200 data points each test.



My data is auto populated into Columns A and B. I need to be able to select all real data in column A, multiply it by a constant and place in a separate column. The problem is that my data in column A varies in the number of cells for each data point. For example, one set of test data will have 800 rows, then next will have 3200. It is always independent and I need to be able to select the entire row regardless of number of rows.



I need to be able to make this a Macro so I can do all of the other data manipulation necessry at once. The problem lies when I create the macro...I use shortcut to select all data and the Macro sees this step as selecting specified cells. So when I record the Macro for an 3200 cell length data point and then try to run it on a 800 cell data point, it selects 3200 cells. I need it to only select real data.










share|improve this question
























  • Have you tried to just put a formula for a single row, and double-click the auto fill button in the bottom right? (I don't think you need a macro to do this...). If you do want to use VBA however, you can loop through the data until it finds the first blank cell.
    – Breakthrough
    Jun 29 '11 at 12:58












  • @Breakthrough, I thought about looping through too and just found out, that you can ignore one blank cell (if a non blank cell is following) with ActiveSheet.UsedRange.Rows.Count But it depends on what point you want to stop counting.
    – Milde
    Jun 29 '11 at 13:34















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a repetitive process that I must do in Excel for test data collected. I have to do this process for every data point I collect. I collect over 200 data points each test.



My data is auto populated into Columns A and B. I need to be able to select all real data in column A, multiply it by a constant and place in a separate column. The problem is that my data in column A varies in the number of cells for each data point. For example, one set of test data will have 800 rows, then next will have 3200. It is always independent and I need to be able to select the entire row regardless of number of rows.



I need to be able to make this a Macro so I can do all of the other data manipulation necessry at once. The problem lies when I create the macro...I use shortcut to select all data and the Macro sees this step as selecting specified cells. So when I record the Macro for an 3200 cell length data point and then try to run it on a 800 cell data point, it selects 3200 cells. I need it to only select real data.










share|improve this question















I have a repetitive process that I must do in Excel for test data collected. I have to do this process for every data point I collect. I collect over 200 data points each test.



My data is auto populated into Columns A and B. I need to be able to select all real data in column A, multiply it by a constant and place in a separate column. The problem is that my data in column A varies in the number of cells for each data point. For example, one set of test data will have 800 rows, then next will have 3200. It is always independent and I need to be able to select the entire row regardless of number of rows.



I need to be able to make this a Macro so I can do all of the other data manipulation necessry at once. The problem lies when I create the macro...I use shortcut to select all data and the Macro sees this step as selecting specified cells. So when I record the Macro for an 3200 cell length data point and then try to run it on a 800 cell data point, it selects 3200 cells. I need it to only select real data.







microsoft-excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 21 '15 at 3:52









Excellll

11k74162




11k74162










asked Jun 29 '11 at 12:50









Rudy

111




111












  • Have you tried to just put a formula for a single row, and double-click the auto fill button in the bottom right? (I don't think you need a macro to do this...). If you do want to use VBA however, you can loop through the data until it finds the first blank cell.
    – Breakthrough
    Jun 29 '11 at 12:58












  • @Breakthrough, I thought about looping through too and just found out, that you can ignore one blank cell (if a non blank cell is following) with ActiveSheet.UsedRange.Rows.Count But it depends on what point you want to stop counting.
    – Milde
    Jun 29 '11 at 13:34




















  • Have you tried to just put a formula for a single row, and double-click the auto fill button in the bottom right? (I don't think you need a macro to do this...). If you do want to use VBA however, you can loop through the data until it finds the first blank cell.
    – Breakthrough
    Jun 29 '11 at 12:58












  • @Breakthrough, I thought about looping through too and just found out, that you can ignore one blank cell (if a non blank cell is following) with ActiveSheet.UsedRange.Rows.Count But it depends on what point you want to stop counting.
    – Milde
    Jun 29 '11 at 13:34


















Have you tried to just put a formula for a single row, and double-click the auto fill button in the bottom right? (I don't think you need a macro to do this...). If you do want to use VBA however, you can loop through the data until it finds the first blank cell.
– Breakthrough
Jun 29 '11 at 12:58






Have you tried to just put a formula for a single row, and double-click the auto fill button in the bottom right? (I don't think you need a macro to do this...). If you do want to use VBA however, you can loop through the data until it finds the first blank cell.
– Breakthrough
Jun 29 '11 at 12:58














@Breakthrough, I thought about looping through too and just found out, that you can ignore one blank cell (if a non blank cell is following) with ActiveSheet.UsedRange.Rows.Count But it depends on what point you want to stop counting.
– Milde
Jun 29 '11 at 13:34






@Breakthrough, I thought about looping through too and just found out, that you can ignore one blank cell (if a non blank cell is following) with ActiveSheet.UsedRange.Rows.Count But it depends on what point you want to stop counting.
– Milde
Jun 29 '11 at 13:34












3 Answers
3






active

oldest

votes

















up vote
0
down vote













It sounds like you are trying to summarize a variable number of columns based on a field.
Try the Subtotal feature and see if that works for you. (see example)



If not, you may have luck using the Lookup & Reference functions to get a reference to where field A changes from 1 to 2, I would then attempt to generate a sum() with an array using the reference as input. Sorry I can't be more detailed, but I've never tried it before.



   A    B
--------
+ 1 1.5
| 1 1.6
| 1 1.7
| 1 1.8
+ 1 1.9
1 Total 7
+ 2 1.5
| 2 1.6
| 2 1.7
| 2 1.8
+ 2 1.9
2 Total 7





share|improve this answer




























    up vote
    0
    down vote













    Here's a macro solution.



    I assumed your data is in column A with a header in cell A1, and you have a column header in column B, cell B1. Paste these 2 code blocks into a module and see if it works for you. The macro to run is MultiplyAllData().



    This first block is a function to get the last row in column A



    Function MyLastRow() As Long
    'This will give the last row in column A
    Dim theLastRow As Long

    Range("A1").Select
    Selection.End(xlDown).Select
    theLastRow = Selection.Row

    MyLastRow = theLastRow
    End Function


    This next block is the macro to run. It multiplies each value in column A by a constant (that you can edit), and puts the result in column B:



    Sub MultiplyAllData()

    Dim ourLastRow As Long
    Dim myConstant As Double

    myConstant = 3.14 'you can edit your constant here

    ourLastRow = MyLastRow 'this is a call to our function

    Range("B2").Select
    ' NOTE: below is the code I got when I first recorded my macro.
    ' I had test data down to cell A40.
    ' ActiveCell.FormulaR1C1 = "=RC[-1]*3.14"
    ' Selection.AutoFill Destination:=Range("B2:B40")
    ' Range("B2:B40").Select
    '
    ' Here is the modified code from the macro, with more flexibility now
    ' because of the variables.
    ActiveCell.FormulaR1C1 = "=RC[-1]*" & myConstant
    Selection.AutoFill Destination:=Range("B2:B" & ourLastRow)
    Range("B2:B" & ourLastRow).Select

    Range("B1").Select 'park the cursor
    End Sub





    share|improve this answer






























      up vote
      0
      down vote













      Rudy:



      I'd use something like this:



      Range(Cells(1,ActiveCell.Column),Cells(WorksheetFunction.CountA(Columns(ActiveCell.Column)),ActiveCell.Column)).Select


      This will select the number of rows containing data starting from row #1 within the active column.






      share|improve this answer





















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f303889%2fselecting-all-data-in-excel-column-regardless-of-size%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        0
        down vote













        It sounds like you are trying to summarize a variable number of columns based on a field.
        Try the Subtotal feature and see if that works for you. (see example)



        If not, you may have luck using the Lookup & Reference functions to get a reference to where field A changes from 1 to 2, I would then attempt to generate a sum() with an array using the reference as input. Sorry I can't be more detailed, but I've never tried it before.



           A    B
        --------
        + 1 1.5
        | 1 1.6
        | 1 1.7
        | 1 1.8
        + 1 1.9
        1 Total 7
        + 2 1.5
        | 2 1.6
        | 2 1.7
        | 2 1.8
        + 2 1.9
        2 Total 7





        share|improve this answer

























          up vote
          0
          down vote













          It sounds like you are trying to summarize a variable number of columns based on a field.
          Try the Subtotal feature and see if that works for you. (see example)



          If not, you may have luck using the Lookup & Reference functions to get a reference to where field A changes from 1 to 2, I would then attempt to generate a sum() with an array using the reference as input. Sorry I can't be more detailed, but I've never tried it before.



             A    B
          --------
          + 1 1.5
          | 1 1.6
          | 1 1.7
          | 1 1.8
          + 1 1.9
          1 Total 7
          + 2 1.5
          | 2 1.6
          | 2 1.7
          | 2 1.8
          + 2 1.9
          2 Total 7





          share|improve this answer























            up vote
            0
            down vote










            up vote
            0
            down vote









            It sounds like you are trying to summarize a variable number of columns based on a field.
            Try the Subtotal feature and see if that works for you. (see example)



            If not, you may have luck using the Lookup & Reference functions to get a reference to where field A changes from 1 to 2, I would then attempt to generate a sum() with an array using the reference as input. Sorry I can't be more detailed, but I've never tried it before.



               A    B
            --------
            + 1 1.5
            | 1 1.6
            | 1 1.7
            | 1 1.8
            + 1 1.9
            1 Total 7
            + 2 1.5
            | 2 1.6
            | 2 1.7
            | 2 1.8
            + 2 1.9
            2 Total 7





            share|improve this answer












            It sounds like you are trying to summarize a variable number of columns based on a field.
            Try the Subtotal feature and see if that works for you. (see example)



            If not, you may have luck using the Lookup & Reference functions to get a reference to where field A changes from 1 to 2, I would then attempt to generate a sum() with an array using the reference as input. Sorry I can't be more detailed, but I've never tried it before.



               A    B
            --------
            + 1 1.5
            | 1 1.6
            | 1 1.7
            | 1 1.8
            + 1 1.9
            1 Total 7
            + 2 1.5
            | 2 1.6
            | 2 1.7
            | 2 1.8
            + 2 1.9
            2 Total 7






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 29 '11 at 13:28









            Chris Nava

            6,80112029




            6,80112029
























                up vote
                0
                down vote













                Here's a macro solution.



                I assumed your data is in column A with a header in cell A1, and you have a column header in column B, cell B1. Paste these 2 code blocks into a module and see if it works for you. The macro to run is MultiplyAllData().



                This first block is a function to get the last row in column A



                Function MyLastRow() As Long
                'This will give the last row in column A
                Dim theLastRow As Long

                Range("A1").Select
                Selection.End(xlDown).Select
                theLastRow = Selection.Row

                MyLastRow = theLastRow
                End Function


                This next block is the macro to run. It multiplies each value in column A by a constant (that you can edit), and puts the result in column B:



                Sub MultiplyAllData()

                Dim ourLastRow As Long
                Dim myConstant As Double

                myConstant = 3.14 'you can edit your constant here

                ourLastRow = MyLastRow 'this is a call to our function

                Range("B2").Select
                ' NOTE: below is the code I got when I first recorded my macro.
                ' I had test data down to cell A40.
                ' ActiveCell.FormulaR1C1 = "=RC[-1]*3.14"
                ' Selection.AutoFill Destination:=Range("B2:B40")
                ' Range("B2:B40").Select
                '
                ' Here is the modified code from the macro, with more flexibility now
                ' because of the variables.
                ActiveCell.FormulaR1C1 = "=RC[-1]*" & myConstant
                Selection.AutoFill Destination:=Range("B2:B" & ourLastRow)
                Range("B2:B" & ourLastRow).Select

                Range("B1").Select 'park the cursor
                End Sub





                share|improve this answer



























                  up vote
                  0
                  down vote













                  Here's a macro solution.



                  I assumed your data is in column A with a header in cell A1, and you have a column header in column B, cell B1. Paste these 2 code blocks into a module and see if it works for you. The macro to run is MultiplyAllData().



                  This first block is a function to get the last row in column A



                  Function MyLastRow() As Long
                  'This will give the last row in column A
                  Dim theLastRow As Long

                  Range("A1").Select
                  Selection.End(xlDown).Select
                  theLastRow = Selection.Row

                  MyLastRow = theLastRow
                  End Function


                  This next block is the macro to run. It multiplies each value in column A by a constant (that you can edit), and puts the result in column B:



                  Sub MultiplyAllData()

                  Dim ourLastRow As Long
                  Dim myConstant As Double

                  myConstant = 3.14 'you can edit your constant here

                  ourLastRow = MyLastRow 'this is a call to our function

                  Range("B2").Select
                  ' NOTE: below is the code I got when I first recorded my macro.
                  ' I had test data down to cell A40.
                  ' ActiveCell.FormulaR1C1 = "=RC[-1]*3.14"
                  ' Selection.AutoFill Destination:=Range("B2:B40")
                  ' Range("B2:B40").Select
                  '
                  ' Here is the modified code from the macro, with more flexibility now
                  ' because of the variables.
                  ActiveCell.FormulaR1C1 = "=RC[-1]*" & myConstant
                  Selection.AutoFill Destination:=Range("B2:B" & ourLastRow)
                  Range("B2:B" & ourLastRow).Select

                  Range("B1").Select 'park the cursor
                  End Sub





                  share|improve this answer

























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    Here's a macro solution.



                    I assumed your data is in column A with a header in cell A1, and you have a column header in column B, cell B1. Paste these 2 code blocks into a module and see if it works for you. The macro to run is MultiplyAllData().



                    This first block is a function to get the last row in column A



                    Function MyLastRow() As Long
                    'This will give the last row in column A
                    Dim theLastRow As Long

                    Range("A1").Select
                    Selection.End(xlDown).Select
                    theLastRow = Selection.Row

                    MyLastRow = theLastRow
                    End Function


                    This next block is the macro to run. It multiplies each value in column A by a constant (that you can edit), and puts the result in column B:



                    Sub MultiplyAllData()

                    Dim ourLastRow As Long
                    Dim myConstant As Double

                    myConstant = 3.14 'you can edit your constant here

                    ourLastRow = MyLastRow 'this is a call to our function

                    Range("B2").Select
                    ' NOTE: below is the code I got when I first recorded my macro.
                    ' I had test data down to cell A40.
                    ' ActiveCell.FormulaR1C1 = "=RC[-1]*3.14"
                    ' Selection.AutoFill Destination:=Range("B2:B40")
                    ' Range("B2:B40").Select
                    '
                    ' Here is the modified code from the macro, with more flexibility now
                    ' because of the variables.
                    ActiveCell.FormulaR1C1 = "=RC[-1]*" & myConstant
                    Selection.AutoFill Destination:=Range("B2:B" & ourLastRow)
                    Range("B2:B" & ourLastRow).Select

                    Range("B1").Select 'park the cursor
                    End Sub





                    share|improve this answer














                    Here's a macro solution.



                    I assumed your data is in column A with a header in cell A1, and you have a column header in column B, cell B1. Paste these 2 code blocks into a module and see if it works for you. The macro to run is MultiplyAllData().



                    This first block is a function to get the last row in column A



                    Function MyLastRow() As Long
                    'This will give the last row in column A
                    Dim theLastRow As Long

                    Range("A1").Select
                    Selection.End(xlDown).Select
                    theLastRow = Selection.Row

                    MyLastRow = theLastRow
                    End Function


                    This next block is the macro to run. It multiplies each value in column A by a constant (that you can edit), and puts the result in column B:



                    Sub MultiplyAllData()

                    Dim ourLastRow As Long
                    Dim myConstant As Double

                    myConstant = 3.14 'you can edit your constant here

                    ourLastRow = MyLastRow 'this is a call to our function

                    Range("B2").Select
                    ' NOTE: below is the code I got when I first recorded my macro.
                    ' I had test data down to cell A40.
                    ' ActiveCell.FormulaR1C1 = "=RC[-1]*3.14"
                    ' Selection.AutoFill Destination:=Range("B2:B40")
                    ' Range("B2:B40").Select
                    '
                    ' Here is the modified code from the macro, with more flexibility now
                    ' because of the variables.
                    ActiveCell.FormulaR1C1 = "=RC[-1]*" & myConstant
                    Selection.AutoFill Destination:=Range("B2:B" & ourLastRow)
                    Range("B2:B" & ourLastRow).Select

                    Range("B1").Select 'park the cursor
                    End Sub






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jun 29 '11 at 14:00

























                    answered Jun 29 '11 at 13:37









                    F106dart

                    1,603118




                    1,603118






















                        up vote
                        0
                        down vote













                        Rudy:



                        I'd use something like this:



                        Range(Cells(1,ActiveCell.Column),Cells(WorksheetFunction.CountA(Columns(ActiveCell.Column)),ActiveCell.Column)).Select


                        This will select the number of rows containing data starting from row #1 within the active column.






                        share|improve this answer

























                          up vote
                          0
                          down vote













                          Rudy:



                          I'd use something like this:



                          Range(Cells(1,ActiveCell.Column),Cells(WorksheetFunction.CountA(Columns(ActiveCell.Column)),ActiveCell.Column)).Select


                          This will select the number of rows containing data starting from row #1 within the active column.






                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Rudy:



                            I'd use something like this:



                            Range(Cells(1,ActiveCell.Column),Cells(WorksheetFunction.CountA(Columns(ActiveCell.Column)),ActiveCell.Column)).Select


                            This will select the number of rows containing data starting from row #1 within the active column.






                            share|improve this answer












                            Rudy:



                            I'd use something like this:



                            Range(Cells(1,ActiveCell.Column),Cells(WorksheetFunction.CountA(Columns(ActiveCell.Column)),ActiveCell.Column)).Select


                            This will select the number of rows containing data starting from row #1 within the active column.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 29 '11 at 20:21









                            kr1stof

                            1




                            1






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Super User!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f303889%2fselecting-all-data-in-excel-column-regardless-of-size%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                AnyDesk - Fatal Program Failure

                                How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

                                QoS: MAC-Priority for clients behind a repeater