Fill variable number of cells with a fixed text

R

Robert

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
 
C

Chip Pearson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top