Microsoft KB Archive/103022: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 26: | Line 26: | ||
http://www.microsoft.com/support/supportnet/overview/overview.asp<br /> | http://www.microsoft.com/support/supportnet/overview/overview.asp<br /> | ||
<br /> | <br /> | ||
The following macro selects a 10-column-wide range every third row. The dimensions of 10 and 3 can be changed to any numbers you want to use. You can also adjust this macro to select a 10-row-deep range every third column by transposing | The following macro selects a 10-column-wide range every third row. The dimensions of 10 and 3 can be changed to any numbers you want to use. You can also adjust this macro to select a 10-row-deep range every third column by transposing "Row_Col" with "0" in cell A8 below and changing "Height" to 10 and "Width" to 1.<br /> | ||
<br /> | <br /> | ||
To select two ranges and leave every third blank, change | To select two ranges and leave every third blank, change "Height" in A4 to 2.<br /> | ||
<br /> | <br /> | ||
Line 34: | Line 34: | ||
=== Sample Macro === | === Sample Macro === | ||
<pre class="FIXEDTEXT"> A1: =SET.NAME( | <pre class="FIXEDTEXT"> A1: =SET.NAME("Reference",!A1) | ||
A2: =SET.NAME( | A2: =SET.NAME("End_Row_Col",100) | ||
A3: =SET.NAME( | A3: =SET.NAME("Step",3) | ||
A4: =SET.NAME( | A4: =SET.NAME("Height",1) | ||
A5: =SET.NAME( | A5: =SET.NAME("Width",10) | ||
A6: =SELECT(Reference) | A6: =SELECT(Reference) | ||
A7: =FOR( | A7: =FOR("Row_Col",0,End_Row_Col,Step) | ||
A8: =SELECT((SELECTION(),OFFSET(Reference,Row_Col,0,Height,Width))) | A8: =SELECT((SELECTION(),OFFSET(Reference,Row_Col,0,Height,Width))) | ||
A9: =NEXT() | A9: =NEXT() | ||
Line 50: | Line 50: | ||
=== Explanation of Macro === | === Explanation of Macro === | ||
<pre class="FIXEDTEXT"> A1: Names the starting cell | <pre class="FIXEDTEXT"> A1: Names the starting cell "Reference." | ||
A2: Defines the name | A2: Defines the name "End_Row_Col" to be the number which, added to the | ||
row or column of | row or column of "Reference", equals the absolute ending row or | ||
column. | column. | ||
A3: | A3: "Step" is the "n" For Every nth row/column. The 3 can be | ||
changed. For example, if you want to select a range of 10 columns | changed. For example, if you want to select a range of 10 columns | ||
every 4 rows, you would change the 3 to 4. | every 4 rows, you would change the 3 to 4. | ||
Line 64: | Line 64: | ||
A5: Sets width when selecting rows. | A5: Sets width when selecting rows. | ||
A6: Selects the range called | A6: Selects the range called "reference." | ||
A7: Begins counting rows or columns. | A7: Begins counting rows or columns. | ||
Line 80: | Line 80: | ||
== REFERENCES == | == REFERENCES == | ||
"Function Reference," version 4.0, pages 154-155, 299-230, 378-379, 383, 384, 389-390<br /> | |||
<br /> | <br /> | ||
"Function Reference," version 3.0, pages 79-80, 163-164, 209-210, 214, 217-218 | |||
Additional query words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 4.00a other nonadjacent non-adjacent discontiguous | Additional query words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 4.00a other nonadjacent non-adjacent discontiguous |
Latest revision as of 09:32, 20 July 2020
XL: XLM Macro to Delete Blank Rows Within a Range |
The information in this article applies to:
- Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a
- Microsoft Excel for OS/2, version 2.2, 3.0
- Microsoft Excel for the Macintosh, versions 2.x, 3.0, 4.0
SUMMARY
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
The following macro selects a 10-column-wide range every third row. The dimensions of 10 and 3 can be changed to any numbers you want to use. You can also adjust this macro to select a 10-row-deep range every third column by transposing "Row_Col" with "0" in cell A8 below and changing "Height" to 10 and "Width" to 1.
To select two ranges and leave every third blank, change "Height" in A4 to 2.
Sample Macro
A1: =SET.NAME("Reference",!A1) A2: =SET.NAME("End_Row_Col",100) A3: =SET.NAME("Step",3) A4: =SET.NAME("Height",1) A5: =SET.NAME("Width",10) A6: =SELECT(Reference) A7: =FOR("Row_Col",0,End_Row_Col,Step) A8: =SELECT((SELECTION(),OFFSET(Reference,Row_Col,0,Height,Width))) A9: =NEXT() A10: =RETURN()
Explanation of Macro
A1: Names the starting cell "Reference." A2: Defines the name "End_Row_Col" to be the number which, added to the row or column of "Reference", equals the absolute ending row or column. A3: "Step" is the "n" For Every nth row/column. The 3 can be changed. For example, if you want to select a range of 10 columns every 4 rows, you would change the 3 to 4. A4: Sets height when selecting columns. A5: Sets width when selecting rows. A6: Selects the range called "reference." A7: Begins counting rows or columns. A8: This statement adds what is selected by the OFFSET() function to what is already selected. Each FOR-NEXT loop adds another row or column. A9: Increments the FOR loop. A10: Ends the macro.
REFERENCES
"Function Reference," version 4.0, pages 154-155, 299-230, 378-379, 383, 384, 389-390
"Function Reference," version 3.0, pages 79-80, 163-164, 209-210, 214, 217-218
Additional query words: 2.0 2.00 2.01 2.1 2.10 2.2 2.20 2.21 3.0 4.00a other nonadjacent non-adjacent discontiguous
Keywords : kbcode kbprg
Version : WINDOWS:2.0,3.0,4.0,4.0a; OS/2:2.2,3.0; MACINTOSH:2.0,3.0,4.0
Platform : MACINTOSH WINDOWS
Issue type :
Technology :
Last Reviewed: November 9, 1999 |