Add Formatting to my procedure...or, Call another module?

Big Lar

Well-known Member
Joined
May 19, 2002
Messages
557
I use this procedure to add values to wsR from wsMembers

I’ve depleted my brain attempting to incorporate formatting of those values If conditions exist…
I’m not sure if my references are correct, but something like:
If wsMembers.Range C2.Offset(, 16).Value =< 4 Then
wsR.Range A3.Font.Italic = True

Or, if Member’s Cell S =< 4 Then
Italicize the value placed in wsR

Or, If Member’s Cell N = “” Then
Add the value in wsR AND “*”

Doable? Or, should I just write and call another module after this procedure?



Code:
Dim Cl As Range
 Dim sKey As String
  Dim wsR As Worksheet
   
   Set wsR = Sheets("R")
   Set wsMembers = Sheets("Members")
  
   With CreateObject("scripting.dictionary")
      For Each Cl In wsMembers.Range("C2", wsMembers.Range("C" & Rows.Count).End(xlUp))
         sKey = Trim(Cl.Value)
        
         If sKey <> "" Then
            .Add sKey, Cl.Offset(, 15).Value
                       
         End If
      Next Cl
  
      For Each Cl In wsR.Range("A3", wsR.Range("A" & Rows.Count).End(xlUp))
         sKey = Trim(Cl.Value)
         Cl.Offset(, 1).Value = .Item(sKey)
  End If
      Next Cl
   End With
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How about
Code:
Sub big_lar()
   Dim Cl As Range
   Dim sKey As String
   Dim wsR As Worksheet, wsMembers As Worksheet
   
   Set wsR = Sheets("R")
   Set wsMembers = Sheets("Members")
   
   With CreateObject("scripting.dictionary")
      For Each Cl In wsMembers.Range("C2", wsMembers.Range("C" & Rows.Count).End(xlUp))
         sKey = Trim(Cl.Value)
         If sKey <> "" Then .Item(sKey) = Array(Cl.Offset(, 15).Value, Cl.Offset(, 16).Value, Cl.Offset(, 11).Value)
      Next Cl
      
      For Each Cl In wsR.Range("A3", wsR.Range("A" & Rows.Count).End(xlUp))
         sKey = Trim(Cl.Value)
         If .Item(sKey)(2) = "" Then
            Cl.Offset(, 1).Value = .Item(sKey)(0) & "*"
         Else
            Cl.Offset(, 1).Value = .Item(sKey)(0)
         End If
         If .Item(sKey)(1) <= 4 Then Cl.Offset(, 1).Font.Italic = True
      Next Cl
   End With
End Sub
 
Upvote 0
FLUFF!!!
Thank you for coming to my rescue, again!
You are a genius...(you probably already know that) :)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Fluff,
How do I italicize the associated data in Cell A when:
If .Item(sKey)(1) <= 4 Then Cl.Offset(, 1).Font.Italic = True

I’ve tried adding
For Each Cl In wsRazz.Range("A2", wsRazz.Range("A" & Rows.Count).End(xlUp))
But obviously it italicizes every name in the range.

As before, suggestions are greatly appreciated.
 
Upvote 0
Simply remove the offset
Code:
If .Item(sKey)(1) <= 4 Then Cl.Font.Italic = True
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top