RicardoCardoso
New Member
- Joined
- Jan 3, 2022
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
I created this macro to count the number of rows starting from column B. Then I created a cycle to fill columns 3,4,5 and 6 with excel formulas. my problem is that the references should be relative and not absolute (b5,b6,b7 and c5, c6,c7...until the last line). I can't finish the macro. Can you help me? Thanks.
Dim lastrow As Long, linha As Integer
lastrow = Range("b5").End(xlDown).Row
For linha = 5 To lastrow
'preenche a coluna dimensao (3)
Cells(linha, 3).Value = "=left(b5,2)*1"
'preenche a coluna tipo (6)
Cells(linha, 6).Value = "=mid(B5,4,4)"
'preenche a coluna 20 (4)
Cells(linha, 4).Value = "=if(c5=20,1,)"
'preenche acoluna 40(5)
Cells(linha, 5).Value = "=if(c5=40,1,)"
MsgBox (linha) & (lastrow)
Next
Dim lastrow As Long, linha As Integer
lastrow = Range("b5").End(xlDown).Row
For linha = 5 To lastrow
'preenche a coluna dimensao (3)
Cells(linha, 3).Value = "=left(b5,2)*1"
'preenche a coluna tipo (6)
Cells(linha, 6).Value = "=mid(B5,4,4)"
'preenche a coluna 20 (4)
Cells(linha, 4).Value = "=if(c5=20,1,)"
'preenche acoluna 40(5)
Cells(linha, 5).Value = "=if(c5=40,1,)"
MsgBox (linha) & (lastrow)
Next