By selecting an option button, I would like macro to enter text into a
particular cell. However, I would like the cell to remain fixed, even if
rows/colums are inserted. Right now, the macro is refering to cell C1, and I
would like it to refer to cell $C$1. Is this possible?
Manty,
Macros are static, and aren't affected by row/column insertions unless you use named ranges, so
you're good to go.
HTH,
Bernie
MS Excel MVPquot;Mantyquot; gt; wrote in message
...
gt; By selecting an option button, I would like macro to enter text into a
gt; particular cell. However, I would like the cell to remain fixed, even if
gt; rows/colums are inserted. Right now, the macro is refering to cell C1, and I
gt; would like it to refer to cell $C$1. Is this possible?
I really should be more specific in my wording:
Range addresses typed into VBA code are static, so
Range(quot;C1quot;).Value = ....
will always point to the current cell C1, no matter what (often to the dismay of the user). There
are many, many ways of writing static code that use ranges in dynamic ways.
HTH,
Bernie
MS Excel MVPquot;Bernie Deitrickquot; lt;deitbe @ consumer dot orggt; wrote in message
...
gt; Manty,
gt;
gt; Macros are static, and aren't affected by row/column insertions unless you use named ranges, so
gt; you're good to go.
gt;
gt; HTH,
gt; Bernie
gt; MS Excel MVP
gt;
gt;
gt; quot;Mantyquot; gt; wrote in message
gt; ...
gt;gt; By selecting an option button, I would like macro to enter text into a
gt;gt; particular cell. However, I would like the cell to remain fixed, even if
gt;gt; rows/colums are inserted. Right now, the macro is refering to cell C1, and I
gt;gt; would like it to refer to cell $C$1. Is this possible?
gt;
gt;
Thanks Bernie,
I think I need to rephrase my question:
Right now the Macro inserts text into cell C1. If I were to insert a row
above that cell, the cell that I was originally inserting the text into would
now be D1 - I need the marco to quot;followquot; the original cell, nomatter where it
goes.
Is this possible?
Rob
quot;Bernie Deitrickquot; wrote:
gt; I really should be more specific in my wording:
gt;
gt; Range addresses typed into VBA code are static, so
gt;
gt; Range(quot;C1quot;).Value = ....
gt;
gt; will always point to the current cell C1, no matter what (often to the dismay of the user). There
gt; are many, many ways of writing static code that use ranges in dynamic ways.
gt;
gt; HTH,
gt; Bernie
gt; MS Excel MVP
gt;
gt;
gt; quot;Bernie Deitrickquot; lt;deitbe @ consumer dot orggt; wrote in message
gt; ...
gt; gt; Manty,
gt; gt;
gt; gt; Macros are static, and aren't affected by row/column insertions unless you use named ranges, so
gt; gt; you're good to go.
gt; gt;
gt; gt; HTH,
gt; gt; Bernie
gt; gt; MS Excel MVP
gt; gt;
gt; gt;
gt; gt; quot;Mantyquot; gt; wrote in message
gt; gt; ...
gt; gt;gt; By selecting an option button, I would like macro to enter text into a
gt; gt;gt; particular cell. However, I would like the cell to remain fixed, even if
gt; gt;gt; rows/colums are inserted. Right now, the macro is refering to cell C1, and I
gt; gt;gt; would like it to refer to cell $C$1. Is this possible?
gt; gt;
gt; gt;
gt;
gt;
gt;
Manty,
Sorry for mis-understanding your question.
Yes. Name cell C1 using Insert / Name / Define. Call it, for example quot;myTextCellquot;
Then in your code, where you have
Range(quot;C1quot;).Value.... (or any other reference to Range(quot;C1quot;))
use
Range(quot;myTextCellquot;).Value....
Note, however, that if Cell C1 gets deleted, then this will fail.
HTH,
Bernie
MS Excel MVPquot;Mantyquot; gt; wrote in message
...
gt; Thanks Bernie,
gt;
gt; I think I need to rephrase my question:
gt;
gt; Right now the Macro inserts text into cell C1. If I were to insert a row
gt; above that cell, the cell that I was originally inserting the text into would
gt; now be D1 - I need the marco to quot;followquot; the original cell, nomatter where it
gt; goes.
gt;
gt; Is this possible?
gt;
gt; Rob
gt;
gt; quot;Bernie Deitrickquot; wrote:
gt;
gt;gt; I really should be more specific in my wording:
gt;gt;
gt;gt; Range addresses typed into VBA code are static, so
gt;gt;
gt;gt; Range(quot;C1quot;).Value = ....
gt;gt;
gt;gt; will always point to the current cell C1, no matter what (often to the dismay of the user).
gt;gt; There
gt;gt; are many, many ways of writing static code that use ranges in dynamic ways.
gt;gt;
gt;gt; HTH,
gt;gt; Bernie
gt;gt; MS Excel MVP
gt;gt;
gt;gt;
gt;gt; quot;Bernie Deitrickquot; lt;deitbe @ consumer dot orggt; wrote in message
gt;gt; ...
gt;gt; gt; Manty,
gt;gt; gt;
gt;gt; gt; Macros are static, and aren't affected by row/column insertions unless you use named ranges, so
gt;gt; gt; you're good to go.
gt;gt; gt;
gt;gt; gt; HTH,
gt;gt; gt; Bernie
gt;gt; gt; MS Excel MVP
gt;gt; gt;
gt;gt; gt;
gt;gt; gt; quot;Mantyquot; gt; wrote in message
gt;gt; gt; ...
gt;gt; gt;gt; By selecting an option button, I would like macro to enter text into a
gt;gt; gt;gt; particular cell. However, I would like the cell to remain fixed, even if
gt;gt; gt;gt; rows/colums are inserted. Right now, the macro is refering to cell C1, and I
gt;gt; gt;gt; would like it to refer to cell $C$1. Is this possible?
gt;gt; gt;
gt;gt; gt;
gt;gt;
gt;gt;
gt;gt;
Bernie,
Works perfectly, thank you very much for your help!
Manty
quot;Bernie Deitrickquot; wrote:
gt; Manty,
gt;
gt; Sorry for mis-understanding your question.
gt;
gt; Yes. Name cell C1 using Insert / Name / Define. Call it, for example quot;myTextCellquot;
gt;
gt; Then in your code, where you have
gt;
gt; Range(quot;C1quot;).Value.... (or any other reference to Range(quot;C1quot;))
gt;
gt; use
gt;
gt; Range(quot;myTextCellquot;).Value....
gt;
gt; Note, however, that if Cell C1 gets deleted, then this will fail.
gt;
gt; HTH,
gt; Bernie
gt; MS Excel MVP
gt;
gt;
gt; quot;Mantyquot; gt; wrote in message
gt; ...
gt; gt; Thanks Bernie,
gt; gt;
gt; gt; I think I need to rephrase my question:
gt; gt;
gt; gt; Right now the Macro inserts text into cell C1. If I were to insert a row
gt; gt; above that cell, the cell that I was originally inserting the text into would
gt; gt; now be D1 - I need the marco to quot;followquot; the original cell, nomatter where it
gt; gt; goes.
gt; gt;
gt; gt; Is this possible?
gt; gt;
gt; gt; Rob
gt; gt;
gt; gt; quot;Bernie Deitrickquot; wrote:
gt; gt;
gt; gt;gt; I really should be more specific in my wording:
gt; gt;gt;
gt; gt;gt; Range addresses typed into VBA code are static, so
gt; gt;gt;
gt; gt;gt; Range(quot;C1quot;).Value = ....
gt; gt;gt;
gt; gt;gt; will always point to the current cell C1, no matter what (often to the dismay of the user).
gt; gt;gt; There
gt; gt;gt; are many, many ways of writing static code that use ranges in dynamic ways.
gt; gt;gt;
gt; gt;gt; HTH,
gt; gt;gt; Bernie
gt; gt;gt; MS Excel MVP
gt; gt;gt;
gt; gt;gt;
gt; gt;gt; quot;Bernie Deitrickquot; lt;deitbe @ consumer dot orggt; wrote in message
gt; gt;gt; ...
gt; gt;gt; gt; Manty,
gt; gt;gt; gt;
gt; gt;gt; gt; Macros are static, and aren't affected by row/column insertions unless you use named ranges, so
gt; gt;gt; gt; you're good to go.
gt; gt;gt; gt;
gt; gt;gt; gt; HTH,
gt; gt;gt; gt; Bernie
gt; gt;gt; gt; MS Excel MVP
gt; gt;gt; gt;
gt; gt;gt; gt;
gt; gt;gt; gt; quot;Mantyquot; gt; wrote in message
gt; gt;gt; gt; ...
gt; gt;gt; gt;gt; By selecting an option button, I would like macro to enter text into a
gt; gt;gt; gt;gt; particular cell. However, I would like the cell to remain fixed, even if
gt; gt;gt; gt;gt; rows/colums are inserted. Right now, the macro is refering to cell C1, and I
gt; gt;gt; gt;gt; would like it to refer to cell $C$1. Is this possible?
gt; gt;gt; gt;
gt; gt;gt; gt;
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt;
gt;
gt;
- Oct 18 Sat 2008 20:46
Help with absolute references in a macro
close
全站熱搜
留言列表
發表留言