Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If cell is not bold, copy to next column; excel

Status
Not open for further replies.

MrsMopey

Programmer
Jul 31, 2007
19
Hello,
I have a name of a product in bold, a description, and a price. The name and description are in teh same column, but in different cells IE:

Name Price
ElevatorELE50-450Basic 4.495
Simpleandrobuststraightelevator
toputtheproduceintothedosinghopperontop
oftheweigher.Topandbottomsideoftheelevatorare
notcovered.Thebeltis500mmwide,4.500mmlongand
hasflightsof75mmheight.

I need to take the description and move it to the description column.

So I would like to do something like this I think;

Code:
For each cell in column a
    if cell.font.bold then
       leave it
    else
       copy cell.value to column b
    end if
next
any suggestions?
 
First, don't do this for every cell in the column unless you want to sit and wait for a few hours while Excel freaks out.

There are a couple of FAQs on the site that discuss how to find the last used row of a range. Click on FAQs at the top of the page to find them.

To test to see if a cell is bold, you'd use something like
[tab]oCell.Font.Bold = True
(or False, if that's easier to code)

To copy data from one cell to another, you'd use something like
[tab]oCell.Offset(0, 1) = oCell.Offset(1, 0)



[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
OK, so the more I thought about this the more it seemed there had to be a better way to parse this out without using the bold. Well ta-dah! I found it, but still unsure how to split it
Each time the word SPECIFICATIONS appears I want to create a new cell

so I was thinking something like
Code:
Sub SplitCell()
Dim ThisDoc As Document
Dim t As Table
Dim r As Row

Set ThisDoc = ActiveDocument
For Each t In ActiveDocument.Tables
    For Each r In t.Rows
        .Execute(findtext:="Specifications", Forward:=True) = True
[b][green]'' I don't know what to code here to split the cell and copy to a new cell [/green][/b]
    Next
Next
End Sub
Am I on the right track at least?
 
I am a little confused as to how this relates to your original sample data and problem but....

IF you need to split cells containing the word "Specifications" then consider:
1. Inserting a new column to the right of the cells to hold everything after "Specifications"
2. Use Edit,Replace to replace "Specifications" with a single character such as ¬ that will not occur normally within the text
3. Use Data,Text to Columns to split the cells using ¬ as the delimiter

Using in-built functionality is often quicker than looping through.

Hope this helps

Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top