Forum Discussion
LeonelAFM
Jul 30, 2022Copper Contributor
Macro VBA Excel - Conditioned copy of reference cell to a range of side cells
First, thanks for the help. I made a test macro for the first time to see if it worked and it was OK. However, it references a single cell due to the test. Now, I need to extend this macro to a ran...
- Jul 30, 2022
Sub Copiar() Dim r As Long Dim n As Long Application.ScreenUpdating = False For r = 104 To 108 n = Application.RoundUp(Range("S" & r).Value, 0) If n <= 0 Then n = 1 ElseIf n > 6 Then n = 6 End If Range("T" & r).Resize(1, n).Value = Range("S" & r).Value Next r Application.ScreenUpdating = True End Sub
Remark: a line such as
If Range("S104") > 1 <= 2 Then
is not valid. It should be
If Range("S104") >1 And Range("S104") <= 2 Then
HansVogelaar
Aug 09, 2022MVP
Book:
Excel VBA Programming for Dummies (don't be put off by the title, it is a seriously helpful book)
Website:
LeonelAFM
Aug 10, 2022Copper Contributor
Thank you one more time my friend!!