Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
1/7/2008 5:40:37 AM EDT
Question #1
I'm trying make a macro to copy column1 taking just the number part of the cells, then add a .jpg extension to fill column2 shown below.  The a's and b's are not part of the image name. I tried many different ways, but can''t get it to work. Any ideas?

column1...............column2
widget 200a..........200.jpg
widget 200b..........200.jpg
widget 210a..........210.jpg

Question #2
I have text in a cell that I want to enclose with html characters for an online catalog description.
Say for example I have;
widget is 100lbs brown 120v

I want to have it say;
<p>widget is 100lbs</p><p> brown</p><p>120v</p>

I can't just highlight text and add a <p> and </p> to the selected text.  All the macros I have tried creating so far are just deleting the entire cell and replacing it with with <p></p>.  I have even tried to insert just a single <p> into existing text with a macro, but the entire contents still get deleted and replaced. I would like to be able to create a few different macros to insert different tags, such as <h1>, <h2>, ect. Can this be done?
1/8/2008 4:39:13 PM EDT
[#1]
Can it be done - yes.

Depending on how exactly you want to use it, dictates how you create it.

For your first question, the simpilest thing to do would be to put the formula

=LEFT(RIGHT(A1, 4), 3) & ".JPG"

into the cell next to the widgets, and changing the cell ref "A1" to whatever you need.  This does, however, assume that the format of the widget name will always have the same spacing.

If it's not a fixed width, but there will always be a space in front of the "image" name, and the last char will always be removed, this should work (it's broken into to cells, just to keep the damned thing from getting so long)
Column 2 formula:

=LEFT(C2,LEN(C2)-1) & ".JPG"


column 3 formula:

=RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2," ","*",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))


Basically, column 3 finds the last "word" in column 1, and colun 2 chops the last char off of the word found by column 3.

Or, use the ffollowing to make a macro (it will create the jpg name one cell to the right of the selected cell - it has the same assumptions as #2 above.


Sub InsertJPGName()
'
' InsertJPGName
' Macro created 1/8/2008 by Boomer8450

Dim sCell As String
Dim iRow As Integer
Dim iColumn As Integer

On Error GoTo errhandler

iRow = ActiveCell.Row
iColumn = ActiveCell.Column + 1

sCell = StrReverse(ActiveCell) 'reverses the string to make it easier to look for the last space
sCell = StrReverse(Left(sCell, InStr(1, sCell, " ") - 1)) 'grabs the last word of the string (first in the reversed string), and flips it back around
Cells(iRow, iColumn).Value = Left(sCell, Len(sCell) - 1) & ".jpg" 'chops of the last char, adds the jpg extention, and sets the target cell to the string

Exit Sub
errhandler:

End Sub


(some of the comments are wrapping in here - make sure they aren't in VBA.)
1/8/2008 4:46:10 PM EDT
[#2]

Quoted:

Question #2
I have text in a cell that I want to enclose with html characters for an online catalog description.
Say for example I have;
widget is 100lbs brown 120v

I want to have it say;
<p>widget is 100lbs</p><p> brown</p><p>120v</p>

I can't just highlight text and add a <p> and </p> to the selected text.  All the macros I have tried creating so far are just deleting the entire cell and replacing it with with <p></p>.  I have even tried to insert just a single <p> into existing text with a macro, but the entire contents still get deleted and replaced. I would like to be able to create a few different macros to insert different tags, such as <h1>, <h2>, ect. Can this be done?


Is this always going to be in description/color/size format, or do you want to be able to highlight the content?

If it's a fixed format, it's not that hard to break it apart in VBA. I've never attempted to grab a user-highlighted section of a cell and send that to VBA. Secondly - have you thought about breaking the the description pieces into seperate columns - it'd be much easier to address the discrete elements that way.
1/10/2008 6:21:16 PM EDT
[#3]

Quoted:
Can it be done - yes.



Damn dude, you are the excel master!  


1/10/2008 9:27:23 PM EDT
[#4]

Quoted:

Quoted:
Can it be done - yes.



Damn dude, you are the excel master!  



Thanks... but the second excel formula I found on the web

1/11/2008 5:46:47 AM EDT
[#5]

Quoted:

Quoted:
Can it be done - yes.



Damn dude, you are the excel master!  




You have no idea how much time that this will save me!!

I have all the manufactures represented by 2 alphanumeric characters for much shorter image filenames. So I tweaked your excel mastery a little and came up with this for column 2;

="wi"&(LEFT(RIGHT(A1,4),3)&".jpg")
This gives me wi200.jpg for the image filename

In column 3, I need another unique name for a smaller thumbnail image and have this;
="wi"&(LEFT(RIGHT(A1,4),3)&"_t.jpg")
My thumbnail image name is now wi200_t.jpg

I'll in the process of adding close to 8000 products in an online catalog for my wife's bridal/formal store and your formula will generate all the image filenames for these products.

Here is a result of your formula at her site, Jilada Designs

Thanks!!!! I'm sure the ARFCOM army could solve virtually any problem!
1/11/2008 6:22:17 PM EDT
[#6]
I'm pretty good w/ Excel, but I'm having a mental block about this one for some silly reason.  

I'm trying to count how many of each state there are:

COMPANY_____STATE
================
Widgets, Inc_____OH
Colstat Corp_____CO
Bing Ind_____CO
Geroge Company_____OH
Ft Collins Manhole Covers_____IA

I want a quick formula that can tell me that there are 2 OH companies, 2 CO companies, 1 Iowa company, etc.

My initial solution started down the path of an index/match to separate them but it's already too clunky.  Suggestions?
1/11/2008 6:59:12 PM EDT
[#7]

Quoted:

Quoted:

Quoted:
Can it be done - yes.



Damn dude, you are the excel master!  



You have no idea how much time that this will save me!!

I have all the manufactures represented by 2 alphanumeric characters for much shorter image filenames. So I tweaked your excel mastery a little and came up with this for column 2;

="wi"&(LEFT(RIGHT(A1,4),3)&".jpg")
This gives me wi200.jpg for the image filename

In column 3, I need another unique name for a smaller thumbnail image and have this;
="wi"&(LEFT(RIGHT(A1,4),3)&"_t.jpg")
My thumbnail image name is now wi200_t.jpg

I'll in the process of adding close to 8000 products in an online catalog for my wife's bridal/formal store and your formula will generate all the image filenames for these products.

Here is a result of your formula at her site, Jilada Designs

Thanks!!!! I'm sure the ARFCOM army could solve virtually any problem!


Glad to have helped

Did you manage to modify the formulas for your HTML tags?

(BTW - given you're at 8,000 records of some sort already, and I'm assuming as you're an arfcommer, and therefore significantly more intelligent and succesful than most, the web store will be growing. This is a really good time to get everything into a true database - even if it's only Access, and break the fields apart as much as possible. It'll make your life so much easier in the long run.)
1/11/2008 7:17:33 PM EDT
[#8]

Quoted:
I'm pretty good w/ Excel, but I'm having a mental block about this one for some silly reason.  

I'm trying to count how many of each state there are:

COMPANY_____STATE
================
Widgets, Inc_____OH
Colstat Corp_____CO
Bing Ind_____CO
Geroge Company_____OH
Ft Collins Manhole Covers_____IA

I want a quick formula that can tell me that there are 2 OH companies, 2 CO companies, 1 Iowa company, etc.

My initial solution started down the path of an index/match to separate them but it's already too clunky.  Suggestions?


Put it in SQL server? (select count(distinct right(ColA, 2)) from ColA)


The closest I've found in a strictly Excel solution is to put

=RIGHT(A1, 2)
into column b, and

=SUM(1/COUNTIF(B1:B5,B1:B5))

at the base of column b, with both ranges adjusted to all of column B.

(formula found using "excel count distinct items" in google.)

ETA: After entering the second formula, it will only work if CTRL+SHFT+ENTER is hit.

1/12/2008 9:49:53 AM EDT
[#9]

Quoted:

Glad to have helped

Did you manage to modify the formulas for your HTML tags?

(BTW - given you're at 8,000 records of some sort already, and I'm assuming as you're an arfcommer, and therefore significantly more intelligent and succesful than most, the web store will be growing. This is a really good time to get everything into a true database - even if it's only Access, and break the fields apart as much as possible. It'll make your life so much easier in the long run.)


I had an old site that used Zencart and I just had too many problems with it.  I did a CSV export of the site and have to manipulate the data to get it right for the current website. I'm using Joomla as the CMS, and a plug-in called Virtuemart for the on-line catalog.  Virtuemart has a csv/Excel upload function that populates the mysql database.  

So...Excel is the best solution for now that I can come up with fixing the old CSV export and adding new products.  I'm a Hybrid/Battery electric powertrain engineer by day, and a web geek for my wife at night.  I just don't have enough time in the day for custom development.  Once I finish with the initial upload to the server database, then I'll customize an Access database to generate the spreadsheet for upload to the server.  #1 priority for now is to get product up and getting search engines looking at the site.

Many of the manufactures do not/will not offer an electronic version or their product/pricing info to the retailers.   I'm forced so scan them, use OCR software to put them in a spreadsheet, then upload the spreadsheet to the database.  

For the HTML tags, I'm just separating info by columns, adding tags with the & function, then combining them all into one column with another & function.