Copy cell contents, then paste into the same cell with other text.

B

bluenote31

Hi!

I tried a search first and couldn't find anything like this. My spreadsheet
has a column for shipping that takes a series like this for each product:

?0.0*0.13.2*d*0x0x0:07:24:04

Following the question mark is the handling charge (0.0 in this example).
This is followed by an * and then the weight of the item (0.13.2 in this
example which is 13.2 ounces)

I have a list of product weights in a colum with just pounds and ounces. I
need to copy that information, then paste it into the weight area of the
string above and then paste those modified contents back into the original
cell the weight was copied from.

So, if the cell contained 1.8.2 (1 LB, 8.2 OZ) then I would want to run
something that would take that and replace it with
?0.0*1.8.2*d*0x0x0:07:24:04.

I know I'm not explaining this well, I'm an excel novice :). Thank you for
any help you can provide.

~Bluenote31
 
R

Ron Rosenfeld

Hi!

I tried a search first and couldn't find anything like this. My spreadsheet
has a column for shipping that takes a series like this for each product:

?0.0*0.13.2*d*0x0x0:07:24:04

Following the question mark is the handling charge (0.0 in this example).
This is followed by an * and then the weight of the item (0.13.2 in this
example which is 13.2 ounces)

I have a list of product weights in a colum with just pounds and ounces. I
need to copy that information, then paste it into the weight area of the
string above and then paste those modified contents back into the original
cell the weight was copied from.

So, if the cell contained 1.8.2 (1 LB, 8.2 OZ) then I would want to run
something that would take that and replace it with
?0.0*1.8.2*d*0x0x0:07:24:04.

I know I'm not explaining this well, I'm an excel novice :). Thank you for
any help you can provide.

~Bluenote31

You could do it with a macro, but where are the other values coming from?

In other words, where is the data that defines the handling charge and the
"*d*0x0x0:07:24:04" ?

--ron
 
D

Don Guillett

More info with before/after examples and criteria or

If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.
 
B

bluenote31

Thanks everyone for your responses. Don, I may take you up on that. I
sincerely appreciate the offer!

Ron, I just went and figured it out... heh. Essentially it breaks down like
this:

?0.0*0.13.2*d*0x0x0:07:24:04

? is just a starting character I believe (I never edit it so I just don't
know, sorry!)
0.0 is the handling fee in dollars and cents.
*0.13.2* is the weight
d* is the package type (rectangular package in this case)
0x0x0 is the package dimensions. they are zeros for me because I use USPS.
:07:24:04 are the package types (first class mail, priority mail flat rate
box, express mail).

Since the product is always DVD's or music, then everything can be prefilled
except for the weight itself. In my colum I have all the weights pasted in
for each item. Now I need to have something that will copy that weight out
of the cell, then paste it into ?0.0*n*d*0x0x0:07:24:04 where "n" is the
weight that was in the column already and then copy the completed string with
the correct weight back into the colum that originally contained the weight
(its all in one column).

Thanks!

~Bluenote31
 
R

Ron Rosenfeld

Ron, I just went and figured it out... heh. Essentially it breaks down like
this:

?0.0*0.13.2*d*0x0x0:07:24:04

? is just a starting character I believe (I never edit it so I just don't
know, sorry!)
0.0 is the handling fee in dollars and cents.
*0.13.2* is the weight
d* is the package type (rectangular package in this case)
0x0x0 is the package dimensions. they are zeros for me because I use USPS.
:07:24:04 are the package types (first class mail, priority mail flat rate
box, express mail).

Since the product is always DVD's or music, then everything can be prefilled
except for the weight itself. In my colum I have all the weights pasted in
for each item. Now I need to have something that will copy that weight out
of the cell, then paste it into ?0.0*n*d*0x0x0:07:24:04 where "n" is the
weight that was in the column already and then copy the completed string with
the correct weight back into the colum that originally contained the weight
(its all in one column).

Thanks!

~Bluenote31

If I understand you correctly, EVERYTHING is fixed in that string except for
the actual weight.

The problem of replacing the original cell contents with your formatted string
can be done with a VBA Macro.

To enter this Macro (Sub), <alt-F11> opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and paste the code below into the
window that opens.

To use this Macro (Sub), first select the range of cells you wish to process.
Then <alt-F8> opens the macro dialog box. Select the macro by name, and <RUN>.

We may have to make some minor changes if your data is not exactly as you've
described.

================================================
Option Explicit
'we will substitute the actual weight for n
Sub EnterWts()
Dim c As Range
Dim sTemp
Const sFmt As String = "?0.0*n*d*0x0x0:07:24:04"
For Each c In Selection
'do rudimentary validation so as not to overwrite
'already processed cells
If c Like "#*.#*.#*" Then
c.Value = Replace(sFmt, "n", c.Value)
End If
Next c
End Sub
======================================
--ron
 
B

bluenote31

That worked great Ron! Thanks so much :). I also modified your work to do
international shipping as well (200 character string) so that saved me a
tremendous amount of time. Thank you again.

I am now trying to edit your work so that I can do something similar, but
with HTML / Text. The " marks are messing me up a bit. Here's what I have
now:

'we will substitute the actual weight for n
Sub EnterWts()
Dim c As Range
Dim sTemp
Const sFmt As String = ""
For Each c In Selection
'do rudimentary validation so as not to overwrite
'already processed cells
'If c Like "#*.#*.#*" Then
c.Value = Replace(sFmt, "vv", c.Value)
'End If
Next c
End Sub

I have a cell which contains a description of the item preformatted in html
like this:

<center>
<p><strong>TITLE</strong></p>
<p><strong>CAPTION</strong></p>
<p> <strong>LANGUAGE</strong></p>
<p><strong> REGION </strong><BR>
</p>
</center><p style="text-align: center"><a target="_blank"
href="http://www.sampleink.com/?action=lookup&id=3187"><img title="view
sample image" alt="" style="border-bottom: 0px; border-left: 0px; border-top:
0px; border-right: 0px"
src="http://www.samplelink.com/images/badge4/3187.png" /></a></p>
<div><strong>Plot Summary: </strong>vv<br /> <br /> <p><strong>My Personal
Top Ten List:<br /> </strong><br /> 1. Tengen Toppa Gurren Lagann<br /> 2.
Furi Kuri (a.k.a. Fooly Cooly or FLCL)<br /> 3. Full Metal Alchemist<br />
4. (The) Melancholy of Haruhi Suzumiya<br /> 5. Welcome to the NHK<br /> 6.
Elfen Lied<br /> 7. Serial Experiments Lain<br /> 8. Xam'd: Lost
Memories<br /> 9. Cowboy Bebop<br /> 10. Bleach</p>

Thats the first section... After this comes a bunch of FAQ stuff that is
also the same for each product. So when I edit your macro it places the
first line <CENTER> in quotes then marks everything else in red (error). I
imagine it has to do with the quotation marks or too many characters or
something... Is there a way for me to modify this line:

Const sFmt As String = ""

....to contain all of my preformated html / text?

Thank you again!

Bluenote31
 
R

Ron Rosenfeld

Const sFmt As String = ""

...to contain all of my preformated html / text?

If your html/text is in, for example G1, then change the Const line to:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top