How can I change the row number in the range().formula

amitcohen

Board Regular
Joined
Jan 14, 2010
Messages
118
Hi Guys
I'm using the following macro to create cells with formulas.
Code:
Sub CreateLoginDetails()
Dim i As Long
Dim lps As Long
lps = Range("C1").Value
For i = lps To 1 Step -1
    With ActiveSheet
        .Range("A" & i).Insert xlShiftDown
        .Range("A" & i).Formula = "TAG POS=1 TYPE=A ATTR=TXT:Log<sp>Out"
        .Range("A" & i).Insert xlShiftDown
        .Range("A" & i).Formula = ""
        .Range("A" & i).Insert xlShiftDown
        .Range("A" & i).Formula = "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:loginform ATTR=ID:wp-submit"
        .Range("A" & i).Insert xlShiftDown
        .Range("A" & i).Formula = "=CONCATENATE(""TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:loginform ATTR=ID:user_login CONTENT="",'DB List'!$C1)"
        .Range("A" & i).Insert xlShiftDown
        .Range("A" & i).Formula = "SET !ENCRYPTION NO"
        .Range("A" & i).Insert xlShiftDown
        .Range("A" & i).Formula = "=CONCATENATE(""TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:loginform ATTR=ID:user_login CONTENT="",'DB List'!$B1)"
        .Range("A" & i).Insert xlShiftDown
        .Range("A" & i).Formula = "=CONCATENATE(""URL GOTO="",'DB List'!$A1)"
    End With
Next i
End Sub
For every loop, I need to change the row number with 1 step.
So first round will populate code for A1, B1, C1.
The next round will populate code for A2, B2, C2.
And so on..
But have to use the "=CONCATENATE()" in the code, I can't find a way to force that change inside the cell.

Hope you have some ideas for me ;)

Thanks,
Amit.</sp>
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Is this it?
Code:
.Range("A" & i).Formula = "=CONCATENATE(""URL GOTO="",'DB List'!$A[COLOR=red][B]" & i & "[/B][/COLOR])"
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top