Alternate grey/red shading with subtitles getting shaded differently (Word table)

Dear Experts:

I got a telephone list/table with the following make-up:

- Each name and corresponding phone number has got its own row.
- The letters A-Z also have their own rows and are formatted bold
- First name, last name is entered in one table cell
- Phone numbers are entered in the table cells next to the "name" cell

With any number rows of the table SELECTED would like the table to
acquire the following FORMATTING:

Rows A, B,C to Z (formatted bold) should have a grey shaded fill (RGB
value 133, 133, 133)
Rows immediately following these subtitles (A-Z) should be shaded
alternately red (239, 211, 210) and grey (133, 133, 133) with the
condition that the alternate cell shading below the subtitles (A to Z)
should always start with a red fill (239, 211, 210).

As I stated above the macro should feature the SELECTION Object.

Help is much appreciated. Thank you very much in advance for your
always terrific help.

Regards, Andreas

SAMPLE TELEPHONE LIST:

A (formatted bold)
Adam, John        069-4553
Atkins, Robert     074-3444
etc.
B (formatted bold)
Bernard, Joe       045-4432
Batton, Jim         743-3983
Beacon, George  345-3597
etc.
C (formatted bold)
Carlos, Santos    435-3993
etc.
0
andreas
3/17/2010 1:35:22 PM
word.vba.general 1023 articles. 1 followers. Follow

2 Replies
1080 Views

Similar Articles

[PageSpeed] 24

A bit of a lash up - but the following should work;

Dim oRow As Row
Dim oRng As Range
Dim bNew As Boolean
On Error Resume Next
bNew = False
With ActiveDocument.Tables(1)
    For Each oRow In .Rows
        Set oRng = oRow.Cells(1).Range
            oRng.End = oRng.End - 1
            If oRng.Characters.Count = 1 And _
            Asc(oRng.Characters(1)) > 64 And _
            Asc(oRng.Characters(1)) < 91 Then
                oRng.Bold = True
                oRow.Shading.BackgroundPatternColor = _
                RGB(133, 133, 133)
            End If
    Next oRow
    For i = 1 To .Rows.Count
        If .Rows(i).Shading.BackgroundPatternColor = _
        RGB(133, 133, 133) Then
            i = i + 1
            bNew = True
        End If
        If bNew = True Then
            .Rows(i).Shading.BackgroundPatternColor = _
            RGB(239, 211, 210)
            bNew = False
            i = i + 1
        End If
        If bNew = False Then
            .Rows(i).Shading.BackgroundPatternColor = _
            RGB(133, 133, 133)
            bNew = True
        End If
    Next i
End With

-- 
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"andreas" <andreas.hermle@gmx.de> wrote in message 
news:6ae2e0da-f76f-49a7-a6b9-0b365c8be372@r27g2000yqn.googlegroups.com...
> Dear Experts:
>
> I got a telephone list/table with the following make-up:
>
> - Each name and corresponding phone number has got its own row.
> - The letters A-Z also have their own rows and are formatted bold
> - First name, last name is entered in one table cell
> - Phone numbers are entered in the table cells next to the "name" cell
>
> With any number rows of the table SELECTED would like the table to
> acquire the following FORMATTING:
>
> Rows A, B,C to Z (formatted bold) should have a grey shaded fill (RGB
> value 133, 133, 133)
> Rows immediately following these subtitles (A-Z) should be shaded
> alternately red (239, 211, 210) and grey (133, 133, 133) with the
> condition that the alternate cell shading below the subtitles (A to Z)
> should always start with a red fill (239, 211, 210).
>
> As I stated above the macro should feature the SELECTION Object.
>
> Help is much appreciated. Thank you very much in advance for your
> always terrific help.
>
> Regards, Andreas
>
> SAMPLE TELEPHONE LIST:
>
> A (formatted bold)
> Adam, John        069-4553
> Atkins, Robert     074-3444
> etc.
> B (formatted bold)
> Bernard, Joe       045-4432
> Batton, Jim         743-3983
> Beacon, George  345-3597
> etc.
> C (formatted bold)
> Carlos, Santos    435-3993
> etc. 


0
Graham
3/17/2010 4:21:58 PM
On Mar 17, 5:21=A0pm, "Graham Mayor" <gma...@REMOVETHISmvps.org> wrote:
> A bit of a lash up - but the following should work;
>
> Dim oRow As Row
> Dim oRng As Range
> Dim bNew As Boolean
> On Error Resume Next
> bNew =3D False
> With ActiveDocument.Tables(1)
> =A0 =A0 For Each oRow In .Rows
> =A0 =A0 =A0 =A0 Set oRng =3D oRow.Cells(1).Range
> =A0 =A0 =A0 =A0 =A0 =A0 oRng.End =3D oRng.End - 1
> =A0 =A0 =A0 =A0 =A0 =A0 If oRng.Characters.Count =3D 1 And _
> =A0 =A0 =A0 =A0 =A0 =A0 Asc(oRng.Characters(1)) > 64 And _
> =A0 =A0 =A0 =A0 =A0 =A0 Asc(oRng.Characters(1)) < 91 Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 oRng.Bold =3D True
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 oRow.Shading.BackgroundPatternColor =3D _
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 RGB(133, 133, 133)
> =A0 =A0 =A0 =A0 =A0 =A0 End If
> =A0 =A0 Next oRow
> =A0 =A0 For i =3D 1 To .Rows.Count
> =A0 =A0 =A0 =A0 If .Rows(i).Shading.BackgroundPatternColor =3D _
> =A0 =A0 =A0 =A0 RGB(133, 133, 133) Then
> =A0 =A0 =A0 =A0 =A0 =A0 i =3D i + 1
> =A0 =A0 =A0 =A0 =A0 =A0 bNew =3D True
> =A0 =A0 =A0 =A0 End If
> =A0 =A0 =A0 =A0 If bNew =3D True Then
> =A0 =A0 =A0 =A0 =A0 =A0 .Rows(i).Shading.BackgroundPatternColor =3D _
> =A0 =A0 =A0 =A0 =A0 =A0 RGB(239, 211, 210)
> =A0 =A0 =A0 =A0 =A0 =A0 bNew =3D False
> =A0 =A0 =A0 =A0 =A0 =A0 i =3D i + 1
> =A0 =A0 =A0 =A0 End If
> =A0 =A0 =A0 =A0 If bNew =3D False Then
> =A0 =A0 =A0 =A0 =A0 =A0 .Rows(i).Shading.BackgroundPatternColor =3D _
> =A0 =A0 =A0 =A0 =A0 =A0 RGB(133, 133, 133)
> =A0 =A0 =A0 =A0 =A0 =A0 bNew =3D True
> =A0 =A0 =A0 =A0 End If
> =A0 =A0 Next i
> End With
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - =A0Word MVP
>
> My web sitewww.gmayor.com
> Word MVP web sitehttp://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
> "andreas" <andreas.her...@gmx.de> wrote in message
>
> news:6ae2e0da-f76f-49a7-a6b9-0b365c8be372@r27g2000yqn.googlegroups.com...
>
>
>
> > Dear Experts:
>
> > I got a telephone list/table with the following make-up:
>
> > - Each name and corresponding phone number has got its own row.
> > - The letters A-Z also have their own rows and are formatted bold
> > - First name, last name is entered in one table cell
> > - Phone numbers are entered in the table cells next to the "name" cell
>
> > With any number rows of the table SELECTED would like the table to
> > acquire the following FORMATTING:
>
> > Rows A, B,C to Z (formatted bold) should have a grey shaded fill (RGB
> > value 133, 133, 133)
> > Rows immediately following these subtitles (A-Z) should be shaded
> > alternately red (239, 211, 210) and grey (133, 133, 133) with the
> > condition that the alternate cell shading below the subtitles (A to Z)
> > should always start with a red fill (239, 211, 210).
>
> > As I stated above the macro should feature the SELECTION Object.
>
> > Help is much appreciated. Thank you very much in advance for your
> > always terrific help.
>
> > Regards, Andreas
>
> > SAMPLE TELEPHONE LIST:
>
> > A (formatted bold)
> > Adam, John =A0 =A0 =A0 =A0069-4553
> > Atkins, Robert =A0 =A0 074-3444
> > etc.
> > B (formatted bold)
> > Bernard, Joe =A0 =A0 =A0 045-4432
> > Batton, Jim =A0 =A0 =A0 =A0 743-3983
> > Beacon, George =A0345-3597
> > etc.
> > C (formatted bold)
> > Carlos, Santos =A0 =A0435-3993
> > etc.- Hide quoted text -
>
> - Show quoted text -

Dear Graham,

what a terrific help! It works as desired. Thank you very much!

Regards, Andreas
0
andreas
3/17/2010 6:47:18 PM
Reply:

Similar Artilces:

how do i find a true value between two different times e.g. 4:15
i would like to find the exact value between two different time in hours and minutes e.g. 4:15 (4 hours 15 minutes) and not 4:42 (4.42 hours) for example. Subtract them! An example: Enter 8:45 in A1 and 5:15 in A2. Enter the formula =A1-A2 in A3 and, voila, the answer is 3:30. Excel will automatically assign the time format to A3 if it has the General number format. -- Jim "Chris01623" <Chris01623@discussions.microsoft.com> wrote in message news:CF16BD54-CC0C-4188-B18D-1C3CE871D95A@microsoft.com... |i would like to find the exact value between two different time in h...

Getting URL Cache Information
Hi, I have to get the URL information for an image. I dont know how to get it. Kindly help me. Thanks a lot. ...

How do I put information into a NEW journal table?
Having created a New table in Outlook 2003 Journal with different column headings (to record family tree history), how can I put information into each of the new headings, which do not appear on the Journal Entry form? You'll need to create a custom fields for the new information. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlooktips.net EMO - a weekly newsletter about Outlook and Exchange: mailto:EMO-NEWS...

How do I insert a clip art picture into a text box in word 2003
Trying to insert a picture into a text box in Word 2003 with very little success. Using Word as some students in the community do not have access to Publisher. Trying to create 4 invitations to a page. Want to use a text box to include text and graphics and then copy and paste four times. Help. Hi Lindas you'ld be better of posting to microsoft.public.word.newusers rather than an excel newsgroup personally, i would use a 2x2 (or 1x4) table in word for this rather than text boxes. Cheers JulieD "Lindas" <Lindas@discussions.microsoft.com> wrote in message news:...

outlook signature is greyed out
for some reason outlook signature is greyed out it was working at one time and we created a new profile and then set up the outlook client and at the point is when this happen. ive seen this before but can not remember what i did to fix it..... Hi - what version of Outlook, and are you using Word as email editor? Best to post this (with more info) to microsoft.public.outlook, as it's not an Exchange issue. James wrote: > for some reason outlook signature is greyed out > it was working at one time and we created a new profile and then set > up the outlook client and at the poi...

Paste Linked Table
Hi Is there any way to paste an already linked table as another linked table as you can do manuualy but programatically? Thanks Martin wrote: >Is there any way to paste an already linked table as another linked table as >you can do manuualy but programatically? A linked table is just another TableDef object with something in its Connect property. That means you can use the DAO CreateTableDef method (see VBA Help) and copy the properties of the existing linked TableDef. That's essentially what Access does when you use Copy/Paste in the Database window. OTOH...

unhide data in pivot table
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I saw that this has been raised before but did not see a solution posted. Has anyone found a workaround? The issue again, I have created a pivot table and in it I ahve e.g columns with data for different years. I want to hide the data on one year and select thehide functionin the fieldsettings and it does disappear neatly, however, when I want to turn this back on it is not possible. It does seem like the cmd button should do the trick when i click it witht he year marked in the fieldsettings, however, it has...

How do I get a cell to remember the last entry and add to it?
I am using Excel 2000. I want my cell to remember the number in it and add an additional number each time I need to retotal. Jab Sounds like you want that cell to be an accumlator cell. Simple question with complex results. You can have a cumulative total in a cell if you have a separate source cell for adding a new total to the original. Use at your own risk. I am Posting this just to show you how it can be done, not as a good solution. You would be much better off to have another column so you can keep track of past entries. Goes like this: =IF(CELL("address")="$C$4&...

getting message interface error and can't send or receive emails
If I try to move or delete an email I get a message - "The message interface has returned an unknown error. If this problem persists restart outlook." I have restarted outlook several times and also re-booted my PC several times. Still to no avail I cannot send or receive emails now either. While Outlook is closed, rename the Outcmd.dat and *.srs files, then open Outlook again and see if this helped. If not, please post back. Also, please post what version of Outlook you're using. If you have reached the limit on your PST, that could cause the error as well. -- Kathleen...

Printing Pivot Table Pie Charts
I have 1400 names in a list each, person has their own data. I created a pivot pie chart to display that data. Can anyone tell me how to print the pivot table so I get a separate sheet for each name selected...without me having to click on the dropdown list each time? Also does anyone know how to hide a field, but have the data still be displayed in the pie chart? thanks ...

Pivot Table
I have 2 lists with approximately 100 items/rows, with 5 pieces of data in each row. Each list has a common element (account number). Many times the account number shows on both lists, and I want to combine How do I combine both lists to use as source data in a pivot table? ...

Cant use word as e-mail editor
If I check Word as e-mail editor in Outlook options, I get following message: "This form requires Word as your e-mail editor, but Word is either busy or cannot be found. The form will be opened in the Outlook editor instead." I de- and re-installed Office XP complete but issue is still occuring. If you open Word, normally, does it run? >-----Original Message----- >If I check Word as e-mail editor in Outlook options, >I get following message: "This form requires Word as your >e-mail editor, but Word is either busy or cannot be >found. The form will be open...

how to get size of text in a Dialog?
MessageBoxes usually size themself according to the text displayed, depending on fontsize and number of chars. can anyone please explain (or point me to an URL where it is explained) how they do it? To keep it simple, lets say we have just a CStatic and a Text in it. How do i get the "optimal" values for the region for MoveWindow() ? ".rhavin grobert" <clqrq@yahoo.de> wrote in message news:1158252329.933561.100380@d34g2000cwd.googlegroups.com... > MessageBoxes usually size themself according to the text displayed, > depending on fontsize and number of char...

getting calendar event reminder for deleted event
I keep getting a reminder for an event that has been deleted from my calendar in Outlook 2002. The event is past due but has been deleted so I get an error message saying there has been an error dismissing the reminder. How can I repair this? I've tried running Scanpst.exe but no joy. thanks, Larry larry.no...@gmail.com wrote: > I keep getting a reminder for an event that has been deleted from my > calendar in Outlook 2002. The event is past due but has been deleted > so I get an error message saying there has been an error dismissing the > reminder. > > How can I...

Totals in pivot table
Hi all, I have a sheet where I store some records in this - simplified - format: Article | quantity XYZ | 4 KLM | -2 XTR | 3 XYZ | -1 There is a minus sign when it's a shipping, otherwise it's a receiving. The pivot table adds/subtracts quantities depending on the sign, and shows for each Article, the quantity available in stock. Once an article quantity become 0, I would like that row to disappear from the pivot table, I dont need a stock list with quantities: 0. Is there a way to do this (not copying the pivot table and removing manually the 0 rows...) thanks ...

Difference between an excel worksheet and XLXS file
I'm a beginner in the world of computer and ms office. On my computer I using Office2007. In excel Icreate a file and saved it as .XLXS file. For the correctons of this file I send to my friend,by using a flash disk. My friend is using Office2003. My file is not oppen on my friend's computer.Why? "Martin" <Martin@discussions.microsoft.com> wrote in message news:8CE55079-436D-411F-BA7B-9C122AB3CFB2@microsoft.com... > I'm a beginner in the world of computer and ms office. On my computer I > using Office2007. In excel Icreate a file and saved it as .XLXS f...

Getting Excel 2000 Options to be remembered
Two questions really: 1. How do I get options for a particular workbook to be saved? I am findng that the option to have R1C1 Reference style to be ticked does not get saved with the workbook but other options do. 2. How can I get options to be either global for all workbooks or for a range of workbooks? Thanks Mervyn Mervyn Unfortunately, R1C1 style is one of those options that is set by the first workbook that is opened in a session. Calculation Mode is another. You could set the R1C1 style in your Personal.xls which will open hidden with each session of Excel, thus ensuring that th...

Merging excel data into word #2
Ok, I have a feeling this process is quite simple, but I haven't bee able to figure it out on my own, nor find anything in FAQ's. I have created an excel spreadsheet containing the following: students' last name, first name, ID number, advisor and counselo (obvioulsy Im in education) I would now like to create a phone call log for each student, but woul like to import each students' info into this word document. So as print the 100 or so pages, page one would have the first students info page two would contain the second students info, and so on. Any help is greatly appre...

'Word is waiting for another application to complete an OLE action'
This happens when attempting to copy a visio file to word, wheter link, embedded or picture. Then is brings up Task Msnager. What is is trying to tell me? We have the same problem on a Windows XP / Office 2002 / Visio 200 configuration. Did you get an answer already ? I would like to know a well. Thanks in advance... Tjeerd karen wrote: > *This happens when attempting to copy a visio file to > word, wheter link, embedded or picture. > Then is brings up Task Msnager. > What is is trying to tell me? - tjeer ---------------------------------------------------------------------...

sending emails from a word userform
Hi everybody, I have created a word userform (in word 2007) and I need to send the data from the userform to a list of employees using the outlook namelist (contact list). there are 2 possibilities to consider: 1. opening the contact list in a stand alone computer 2. opening the contact list with activex control (for a big organization). can someone tell me how to do that please? If you are continually sending this data to the same bunch of employees, you could set up a distribution list. Write the form data to a new document and then call the following macro to send the d...

How to get email statistics from exch2003?
Hi there, I would like to know for last month, 1. how many incoming internet emails 2. how many outgoing internet emails Wondering how can I check that on exchange2003? Many thanks! On Fri, 13 May 2005 10:57:31 +0800, "Zac" <zacfang@hotmail.com> wrote: >Hi there, > >I would like to know for last month, > >1. how many incoming internet emails > >2. how many outgoing internet emails > >Wondering how can I check that on exchange2003? > >Many thanks! > You can get this information if you have Message Tracking enabled on your servers. I...

how to work writefile function with Microsoft Word
Hi, If we write any DOC file using MS Word i think we need ReadFile CreateFile WriteFile FlushFileBuffers CloseFile above functions.... Can anyone tell me what happned between WriteFile & closefile functions. if i hook WriteFile function & im using it like:::: BOOL WINAPI _WriteFile( HANDLE hFile, // handle to file to write to LPCVOID lpBuffer, // pointer to data to write to file DWORD nNumberOfBytesToWrite, // number of bytes to write LPDWORD lpNumberOfBytesWritten, // pointer to number of bytes...

Text Encoding Problem
I asked a friend to translate a letter I wrote in English to Hungarian, and she sent me back the translation via email. I then copied the text from the email message in Entourage and pasted it into a Word document. All of the instances of a letter that looks like an o with a double apostrophe over it (if it comes through this is it: ő ) in Entourage carries over into Wrd as something that looks like a capital O and capital E squashed together (if it comes through this is it: Œ ). How can I get the proper character to display in my Word document ??? ...

get rid of paragraph indent...accidently in emails
Somehow there is a backwards P "paragraph indent" on my ermails, and I need to know how to eliminate it.... "Dawn" <Dawn@discussions.microsoft.com> wrote in message news:AA23C7BB-D12A-4D24-8C2E-1A227481C80B@microsoft.com... > Somehow there is a backwards P "paragraph indent" on my ermails, and I > need > to know how to eliminate it.... That is not an issue with Outlook. That is an issue on how you configured Word to show special formatting characters. The folks in the Word newsgroup can tell you where is the option but might need more spe...

Difference between wmemcmp and memcmp
I was just wondering what the difference between the two? It seems that both functions just take in bytes as their last parameter, and if it does a raw memory comparison for the amount of bytes specified, than it doesn't matter whether it is unicode or not? Also, I am looking for a function that just compares memory one byte at a time.. regardless of whether it is unicode or not.. what function should I be using? Thanks It seems silly to have wmemcmp since, as you pointed out, memcmp() is traditionally byte-oriented. If you want to compare arrays of Unicode characters, use wmemcmp()...