Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2018, 12:45 PM
sophiebatch sophiebatch is offline Conditional formating table Windows 10 Conditional formating table Office 2016
Novice
Conditional formating table
 
Join Date: Jan 2018
Posts: 2
sophiebatch is on a distinguished road
Question Conditional formating table

Hi there,



I'm using a word template together with an online based inventory management system. It allows me to print out picking lists etc. I was wondering if I could manipulate the information so that depending on a prefix the font is changing. So if I have "IH1-" in one row it would automatically write it in red or write it in bold.
I've attached the word document we're using which should make it easier to undertstand On the word document the cell I'm refering to is code <<Product Code>> Plus you can also find the finished pdf. file.

Hope some one knows if it's possible. Also just a little hint to the right direction would be more then I can ask for.

Many thanks,

Sophie
Attached Files
File Type: docx BatchOrganics 1.docx (44.9 KB, 18 views)
File Type: pdf Batch1 SO-00384 for SophieSchrittenloher (1).pdf (63.1 KB, 11 views)
Reply With Quote
  #2  
Old 01-15-2018, 02:12 PM
macropod's Avatar
macropod macropod is offline Conditional formating table Windows 7 64bit Conditional formating table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See Conditionally Shade Table Cells in the Mailmerge Tips and Tricks Sticky thread at the top of this forum:
https://www.msofficeforums.com/mail-...ps-tricks.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-18-2018, 05:12 PM
kilroy kilroy is offline Conditional formating table Windows 10 Conditional formating table Office 2016
Competent Performer
 
Join Date: Sep 2016
Location: Southern Ontario
Posts: 118
kilroy is on a distinguished road
Default

Based on the Word document you supplied the following code allows you to choose the text you want to find and choose the column it looks in. I'm sure it could probably be cleaned up. I believe this code was originally written by Greg Maxey but butchered by me to suit your needs.

Code:
Sub BoldRowBasedOnString()
 
Dim strName As String
Dim oDoc As Document
    Dim oTbl As Table
    Dim oCell As Cell
    Dim oRow As Row
    Dim strText As String, strRef As String
    Dim lngCol As Long
    Dim oRng As range
    Set oDoc = ActiveDocument
    Set oTbl = oDoc.Tables(2)
    strText = InputBox("Search text?")
    lngCol = CLng(InputBox("Enter column to search", "Must be 1 - 5"))
    For Each oCell In oTbl.range.Cells
    If oCell.RowIndex > 1 And oCell.ColumnIndex = lngCol Then
            On Error Resume Next
            If Left(oTbl.Cell(oCell.RowIndex, 1).range.Text, Len(oTbl.Cell(oCell.RowIndex, 1).range.Text) - 2) <> vbNullString Then
                strRef = Left(oTbl.Cell(oCell.RowIndex, 1).range.Text, Len(oTbl.Cell(oCell.RowIndex, 1).range.Text) - 2)
            End If
            If Left(oTbl.Cell(oCell.RowIndex, 1).range.Text, Len(oTbl.Cell(oCell.RowIndex, 1).range.Text) - 2) = vbNullString Then
                oTbl.Cell(oCell.RowIndex, 1).range.Text = strRef
            End If
            On Error GoTo 0
            If InStr(UCase(oCell.range.Text), UCase(strText)) > 0 Then
               oCell.range.Select
               With Selection
                  Selection.SelectRow
                  Selection.BoldRun
               End With
            End If
    End If
    Next
lbl_Exit:
    Set oDoc = Nothing: Set oTbl = Nothing: Set oCell = Nothing
    Exit Sub
    End Sub
Reply With Quote
  #4  
Old 01-18-2018, 06:09 PM
macropod's Avatar
macropod macropod is offline Conditional formating table Windows 7 64bit Conditional formating table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Since the document is for use with a mailmerge, I can't see the point of running a macro when the highlighting can be done during the merge itself; the macro would have to be run on the output document after the merge has been executed, thus adding an extra step to the process.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-14-2018, 08:09 AM
sophiebatch sophiebatch is offline Conditional formating table Windows 10 Conditional formating table Office 2016
Novice
Conditional formating table
 
Join Date: Jan 2018
Posts: 2
sophiebatch is on a distinguished road
Default

Thanks for giving me so much input!

I shall try to figure it out now!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formating SHolm Outlook 1 01-09-2018 08:37 PM
Conditional formating table Conditional Formating? wilabern Excel 6 12-13-2017 10:08 AM
Conditional formating table Conditional formating MJS16 Excel 16 12-01-2016 01:09 PM
Conditional formating table Conditional Formating Aseren Excel 14 02-18-2016 01:05 PM
Conditional formating table more Conditional Formating princeofsadness Excel 2 09-05-2011 02:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft