+ Reply to Thread
Results 1 to 2 of 2

Auto Fill or Macro

  1. #1
    Registered User
    Join Date
    02-01-2009
    Location
    Ohio, United States
    MS-Off Ver
    Excel 2003
    Posts
    1

    Auto Fill or Macro

    1st I would like to say what a great forum.

    I have an odd list that I would like to auto fill or write a macro for because it contains around 5000 entries.

    I have 2 columns:

    Stock Num txtStockGraph
    MSS80000 MSS80000\MSS80000
    MSS80001 MSS80001\MSS80001
    MSS80002 MSS80002\MSS80002
    MSS80003 MSS80003\MSS80003
    MSS80004 MSS80004\MSS80004
    MSS80005 MSS80005\MSS80005
    MSS80006 MSS80006\MSS80006
    MSS80007 MSS80007\MSS80007
    MSS80008 MSS80008\MSS80008
    MSS80009 MSS80009\MSS80009
    MSS80010 MSS80010\MSS80010

    (And so-on)

    Now I have 2 problems - I need the column with stock numbers to be relisted as:

    Stock Num txtStockGraph
    MSS80000a MSS80000\MSS80000a.jpg
    MSS80000b MSS80000\MSS80000b.jpg
    MSS80000c MSS80000\MSS80000c.jpg
    MSS80000d MSS80000\MSS80000d.jpg
    MSS80000e MSS80000\MSS80000e.jpg
    MSS80000f MSS80000\MSS80000f.jpg

    (and so-on)

    So for each instance of stock number I need an a,b,c,d,e, and f version of the number. Then in the second column, the folder and then the same corresponding a,b,c,d,e,and f as well as ".jpg" at the end.

    I can probably figure out the 2nd part - but I am stumped on the 1st.

    Any help appreciated!
    Last edited by Doc203; 02-01-2009 at 10:19 PM.

  2. #2
    Chris Bode
    Guest

    Re: Auto Fill or Macro

    Please follow following steps
    1.Right click toolbar>select control box
    2.From the control box that appears on your sheet draw a command button
    3.Double click the command button to view the code window and paste following codes

    Private Sub CommandButton1_Click()
    Dim row As Integer, col As Integer
    row = 1
    col = 1

    Dim str1 As String, str2 As String
    Dim i As Integer

    Dim nextrow As Integer, nextcol As Integer
    nextrow = 1
    nextcol = 4
    While Sheet1.Cells(row, col).Value <> ""
    str1 = Sheet1.Cells(row, col).Value
    str2 = Sheet1.Cells(row, col + 1).Value

    nextrow = 1

    For i = Asc("a") To Asc("f")
    Sheet1.Cells(nextrow, nextcol).Value = str1 + Chr(i)
    Sheet1.Cells(nextrow, nextcol + 1).Value = str1 + "\" + str1 + Chr(i) + ".jpg"

    nextrow = nextrow + 1
    Next

    row = row + 1
    Wend
    End Sub

    Have a nice time……


    Chris
    Last edited by VBA Noob; 02-15-2009 at 06:36 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1