ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill variable number of cells with a fixed text (https://www.excelbanter.com/excel-programming/393093-fill-variable-number-cells-fixed-text.html)

Robert[_30_]

Fill variable number of cells with a fixed text
 
Hi All,

I am struggling with the following: I've created a VBA statement that
compiles a certain file using different input sheets. At some point I
want to add a fixed description in column B in case there is a value
in column A

To make it a bit more visible:

A B (to be covered by a VBA statement)
1 EUR Fx Forward
2 GBP Fx Forward
3 USD Fx Forward
4 CHF Fx Forward
5 SGD Fx Forward

Note: the number of cells in column A varies through time

Can someone perhaps tell me which statement I can use best?

Many thanks in advance!
Rgds,
Robert


Chip Pearson

Fill variable number of cells with a fixed text
 
Try something like

Sub AAA()
Dim RowNdx As Long
Dim StartRow As Long
Dim EndRow As Long

StartRow = 1 '<<< CHANGE IF NEEDED
EndRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = StartRow To EndRow
If Cells(RowNdx, "A").Value < vbNullString Then
Cells(RowNdx, "B").Value = "ABCD"
End If
Next RowNdx
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Robert" wrote in message
oups.com...
Hi All,

I am struggling with the following: I've created a VBA statement that
compiles a certain file using different input sheets. At some point I
want to add a fixed description in column B in case there is a value
in column A

To make it a bit more visible:

A B (to be covered by a VBA statement)
1 EUR Fx Forward
2 GBP Fx Forward
3 USD Fx Forward
4 CHF Fx Forward
5 SGD Fx Forward

Note: the number of cells in column A varies through time

Can someone perhaps tell me which statement I can use best?

Many thanks in advance!
Rgds,
Robert




All times are GMT +1. The time now is 01:26 AM.

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