excelman15
New Member
- Joined
- Dec 16, 2022
- Messages
- 6
- Office Version
- 2021
- 2019
- 2016
- Platform
- Windows
Hi Guys,
Can someone please help me to correct my VBA code to achieve my requirement please.
I have a range of IP using which I want to create a command and I want to do this via macros.
The command part will be same every time, only part that will change is IP. So, I'm trying to achieve this via macros.
Below code is working but it is only reading one value instead of the column.
Expectation:
1. Column will contain n number of IP. So, I want this code to read whole column.
2. The first and last text will be same every time. That's why I want hard code that in the code. This way I will just use the macros on a column and it will automatically print the output using values of the selected column.
Data:
Expected output:
Can someone please help me to correct my VBA code to achieve my requirement please.
I have a range of IP using which I want to create a command and I want to do this via macros.
The command part will be same every time, only part that will change is IP. So, I'm trying to achieve this via macros.
Below code is working but it is only reading one value instead of the column.
Expectation:
1. Column will contain n number of IP. So, I want this code to read whole column.
2. The first and last text will be same every time. That's why I want hard code that in the code. This way I will just use the macros on a column and it will automatically print the output using values of the selected column.
Code:
Private Sub Concate()
lastrow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
Dim myAry(0 To 2) As String
Dim b As String
For i = 2 To lastrow
b = Cells(i, 1).Value
Next
myAry(0) = "add host name"
myAry(1) = b
myAry(2) = "value set"
Range("A15").Value = Join(myAry)
End Sub
Data:
172.16.1.1 |
172.16.1.2 |
172.16.1.3 |
Expected output:
add host name 172.16.1.1 set value |
add host name 172.16.1.2 set value |
add host name 172.16.1.3 set value |