Simple question

R

Robert

Hi All,

With the below statement I am trying to put "EUR" in column C as long
as there is a value in column A. Unfortunately column C stays empty.
Does anyone know what goes wrong or should I use a different
statement?

Thanks a lot!
Regards,
Robert


Dim aLastRow As Long, aNextRow As Long
Dim a As Long
aNextRow = 5
With Worksheets("BarraFormatLiabilities")
aLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For a = 1 To aLastRow
If .Cells(a, "A").Value = "" Then
aNextRow = aNextRow + 1
.Cells(a, "C").Value = "EUR"
Value.Paste
End If
Next a
End With
 
J

Joel

The only thing I see wrong is you don't need the dot infront of rows.count.
there is also things you don't need in the code. He is the fixed code

Dim aLastRow As Long
Dim a As Long
With Worksheets("BarraFormatLiabilities")
aLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For a = 1 To aLastRow
if .Cells(a, "A").Value = "" Then
.Cells(a, "C").Value = "EUR"
End If
Next a
End With
 
R

Robert

Hi Joal,
Thanks for your support!
I changed the code but still no values in column C...
Forgot to mention that the if then should start at row5.
Rgds,
Robert
 
J

Joel

I think your text is backwards, try this code. I changed = to <>

Dim aLastRow As Long
Dim a As Long
With Worksheets("BarraFormatLiabilities")
aLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For a = 5 To aLastRow
if .Cells(a, "A").Value <> "" Then
.Cells(a, "C").Value = "EUR"
End If
Next a
End With
 

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