Reputation: 195
I am naive to macros. I have data in column A with 500 rows of data. Note some rows are blank in between. The data are image files names like ([email protected]). I need to rename them sequentially with user input. The user input must be only 400500. The new name must be like (400500_Image-1.jpg). The _Image-1, _Image-2 and so on must be generated automatically in sequence omitting blank rows.
See below how my data is displayed in column A and how I want it in column B.
I appreciate if anyone can provide macro for this.
Col A Col B
[email protected] 400500_Image-1.jpg
[email protected] 400500_Image-2.jpg
[email protected] 400500_Image-3.jpg
[email protected] 400500_Image-4.jpg
[email protected] 400500_Image-5.jpg
[email protected] 400500_Image-6.jpg
[email protected] 400500_Image-7.jpg
[email protected] 400500_Image-8.jpg
Thanks
Upvotes: 0
Views: 29
Reputation: 140
Sub naming()
RowsToProcess = Range("A" & Rows.Count).End(xlUp).Row
j = 1
userInput = InputBox("Give me text")
For i = 1 To RowsToProcess
If Not Cells(i, 1).Value = "" Then
Cells(i, 2).Value = userInput & "_Image-" & j & ".jpg"
j = j + 1
End If
Next
End Sub
This macro creates column B as desired
Upvotes: 1