ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to program the equal filling out of an individual selction of fields? (https://www.excelbanter.com/excel-programming/375096-how-program-equal-filling-out-individual-selction-fields.html)

Marcel Marien

how to program the equal filling out of an individual selction of fields?
 
Can anybody tell me how it is possible in Excel (office 2000) to insert by
program a certain content into a selection of single fields from different
colums and rows without altering their format? It would be the equivalent to
manually inserting a copied value into a selection of fields.

Thank you very much in advance,
Marcel



Gary''s Student

how to program the equal filling out of an individual selction of
 
Enter this tiny macro:

Sub gsnu()
Dim v As Variant
v = InputBox("Enter content: ")
For Each r In Selection
r.Value = v
Next
End Sub

First select the cells you want to fill and run the macro.
--
Gary's Student


"Marcel Marien" wrote:

Can anybody tell me how it is possible in Excel (office 2000) to insert by
program a certain content into a selection of single fields from different
colums and rows without altering their format? It would be the equivalent to
manually inserting a copied value into a selection of fields.

Thank you very much in advance,
Marcel




Marcel Marien

how to program the equal filling out of an individual selction of fields?
 
Maybe I haven't stated my problem very clearly.
I want to select a number of cells which do not neccessarily have to be
adjacent. Then I want to assign a value to all those cells, but without
altering their format. I have been trying 2 ways:

1)
Selection.Value = "x"

This will put the value "x" in all cells, if the cells are placed in a
continuous column and are selected from top to bottom. If they are selected
from bottom to top or if they are not adjacent, then *only* the 1st of the
selected cells is filled with an "x"

2)
ActiveCell.FormulaR1C1 = "a"
ActiveCell.Copy

This behaves just as does version 1). It generally puts an "x" *only* into
the 1st of the selected cells.

Thanks a lot in advance,
Marcel


"Marcel Marien" schrieb im Newsbeitrag
...
Can anybody tell me how it is possible in Excel (office 2000) to insert by
program a certain content into a selection of single fields from different
colums and rows without altering their format? It would be the equivalent
to manually inserting a copied value into a selection of fields.

Thank you very much in advance,
Marcel




Zone

how to program the equal filling out of an individual selction of fields?
 
Give this a try. James

Sub InsVal()
Dim t As Integer, c As Long
With Selection
For t = 1 To .Areas.Count
For c = 1 To .Areas(t).Cells.Count
.Areas(t).Cells(c) = "x"
Next c
Next t
End With
End Sub

Marcel Marien wrote:
Maybe I haven't stated my problem very clearly.
I want to select a number of cells which do not neccessarily have to be
adjacent. Then I want to assign a value to all those cells, but without
altering their format. I have been trying 2 ways:

1)
Selection.Value = "x"

This will put the value "x" in all cells, if the cells are placed in a
continuous column and are selected from top to bottom. If they are selected
from bottom to top or if they are not adjacent, then *only* the 1st of the
selected cells is filled with an "x"

2)
ActiveCell.FormulaR1C1 = "a"
ActiveCell.Copy

This behaves just as does version 1). It generally puts an "x" *only* into
the 1st of the selected cells.

Thanks a lot in advance,
Marcel


"Marcel Marien" schrieb im Newsbeitrag
...
Can anybody tell me how it is possible in Excel (office 2000) to insert by
program a certain content into a selection of single fields from different
colums and rows without altering their format? It would be the equivalent
to manually inserting a copied value into a selection of fields.

Thank you very much in advance,
Marcel



Marcel Marien

how to program the equal filling out of an individual selction of fields?
 
Dear James,

thanks for your solution. In the meantime I have found out that the
solution:
Selection.Value = "x"
works perfectly fine - only that by mistake I kept calling the wrong macro
and thus everything I tried seemed to yield no result.

Marcel


"Zone" schrieb im Newsbeitrag
ups.com...
Give this a try. James

Sub InsVal()
Dim t As Integer, c As Long
With Selection
For t = 1 To .Areas.Count
For c = 1 To .Areas(t).Cells.Count
.Areas(t).Cells(c) = "x"
Next c
Next t
End With
End Sub

Marcel Marien wrote:
Maybe I haven't stated my problem very clearly.
I want to select a number of cells which do not neccessarily have to be
adjacent. Then I want to assign a value to all those cells, but without
altering their format. I have been trying 2 ways:

1)
Selection.Value = "x"

This will put the value "x" in all cells, if the cells are placed in a
continuous column and are selected from top to bottom. If they are
selected
from bottom to top or if they are not adjacent, then *only* the 1st of
the
selected cells is filled with an "x"

2)
ActiveCell.FormulaR1C1 = "a"
ActiveCell.Copy

This behaves just as does version 1). It generally puts an "x" *only*
into
the 1st of the selected cells.

Thanks a lot in advance,
Marcel


"Marcel Marien" schrieb im Newsbeitrag
...
Can anybody tell me how it is possible in Excel (office 2000) to insert
by
program a certain content into a selection of single fields from
different
colums and rows without altering their format? It would be the
equivalent
to manually inserting a copied value into a selection of fields.

Thank you very much in advance,
Marcel





Zone

how to program the equal filling out of an individual selction of fields?
 
Marcel, thanks for clarifying this. Your solution is clearly more
elegant. I think I had tried this before, but I was probably trying to
apply formatting at the same time, which will not work this way, as I
recall, so my advice was not the most elegant. The best part of this
site is that when I attempt to help someone I almost always learn
something, as well. James

Marcel Marien wrote:
Dear James,

thanks for your solution. In the meantime I have found out that the
solution:
Selection.Value = "x"
works perfectly fine - only that by mistake I kept calling the wrong macro
and thus everything I tried seemed to yield no result.

Marcel


"Zone" schrieb im Newsbeitrag
ups.com...
Give this a try. James

Sub InsVal()
Dim t As Integer, c As Long
With Selection
For t = 1 To .Areas.Count
For c = 1 To .Areas(t).Cells.Count
.Areas(t).Cells(c) = "x"
Next c
Next t
End With
End Sub

Marcel Marien wrote:
Maybe I haven't stated my problem very clearly.
I want to select a number of cells which do not neccessarily have to be
adjacent. Then I want to assign a value to all those cells, but without
altering their format. I have been trying 2 ways:

1)
Selection.Value = "x"

This will put the value "x" in all cells, if the cells are placed in a
continuous column and are selected from top to bottom. If they are
selected
from bottom to top or if they are not adjacent, then *only* the 1st of
the
selected cells is filled with an "x"

2)
ActiveCell.FormulaR1C1 = "a"
ActiveCell.Copy

This behaves just as does version 1). It generally puts an "x" *only*
into
the 1st of the selected cells.

Thanks a lot in advance,
Marcel


"Marcel Marien" schrieb im Newsbeitrag
...
Can anybody tell me how it is possible in Excel (office 2000) to insert
by
program a certain content into a selection of single fields from
different
colums and rows without altering their format? It would be the
equivalent
to manually inserting a copied value into a selection of fields.

Thank you very much in advance,
Marcel





All times are GMT +1. The time now is 03:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com