Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I can edit some VB code, but I dont know enough Visual Basic to create a macro t

ID: 3563331 • Letter: I

Question

I can edit some VB code, but I dont know enough Visual Basic to create a macro to do this:

Example:

      a         b        c       d       e         f         g          h       I        j

1   1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg 7.jpg 8.jpg 9.jpg 10.jpg --> 28.jpg

2   29.jpg ----------------------------------------------------------------> 56.jpg

3   57.jpg ----------------------------------------------------------------> 84.jpg

4   85.jpg ----------------------------------------------------------------> 112.jpg

etc

At first i was trying to find a formula (and pulling out my hair in the process) that would allow me to autonumber and include &".jpg" to the end so that I could type the first number of each row and fill to the end, in increments of 28. Similar to what =row()&".jpg" does but horizontally instead of vertically. If there is a space (1 .jpg) it works fine but that does not work for me because its invalid for an image name. Excel does not like the period touching the number.

I figured out that i can just use a qualifier, in this case the unwanted " " space, do a find and replace to remove the space. But.. this still leaves me with tons of work. I need Thousands of rows filled out in increments of 28 and its just not practical to drag and fill each row manually... it would probably take me a week of work just to finish the import file, just in time to do it all over again and never getting to start the real work I have to get done... It has to be in this formatting for photoshop .CSV import.

Please, if any Macro Guru is reading this I could really use your help!

Explanation / Answer

Try a macro?

Can go either way with this one.

Sub FillNums()
'to fill rows and columns with numbers from 1 to whatever
Dim nrows As Integer
Dim ncols As Integer
    On Error GoTo quitnow
    RowsorCols = InputBox("Fill Across = 1" & Chr(13) _
            & "Fill Down = 2")
    num = 1
    nrows = InputBox("Enter Number of Rows")
    ncols = InputBox("Enter Number of Columns")
    If RowsorCols = 1 Then
        For across = 1 To nrows
            For down = 1 To ncols
                ActiveSheet.Cells(across, down).Value = num & ".jpg"
                num = num + 1
            Next down
        Next across
    Else
        For across = 1 To ncols
            For down = 1 To nrows
                ActiveSheet.Cells(down, across).Value = num & ".jpg"
                num = num + 1
            Next down
        Next across
    End If
quitnow:
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote