Highlights only last rows

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,

I am looking if someone can make VBA that can highlights last rows in the column C:H as per data last data row column K:Q as per example below


Book1
ABCDEFGHIJKLMNOPQ
1
2
3
4NYearn1n2n3n4n5n6n7EM1N1N2N3N4N5N6N7
5NYearn1n2n3n4n5n6n7EM1N1N2N3N4N5N6N7
6170/71X1121211322541
7270/7121XX2225142214
8370/7121211221135211
9470/711XX111X5521145
10570/71212XX1X2223611
11670/71222111X1612211
12770/71111X2223262544
13870/711X112121412121
14970/7111211X112313108
151070/71221X1224423132
161170/712XXX2121371331
171270/7121X222213111121
181370/7112XX2124312121
191470/71XX1121113345115
201570/7111221122363512
211670/71X2112212322242
221770/71112X11X22242211
231870/7112X11221252123
241970/7121212117221323
252070/71112XX1121131511
262170/71211X2122151213
272270/711X212112823112
282370/7112XX2221552152
292470/71X1X21128319621
302570/71X1111211143123
312670/71122222X3342319
32
33
Sheet10


Thank you all
Excel 2000
Regards,
Moti
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Thank you MickG, What if I ask can you make it could be highlighted in 2 alternate colours like cyan and green (I mean to say row 11 in cyan row 20 in green row 22 in cyan may be)
Regards,
Moti

MickG, after applying the code with my full data I think it is fine as you supplied the code, alternative colours will be the disturbing sorry for the hassle.

Thank you, have a nice day

Good luck!

Regards,
Moti


 
Last edited:
Upvote 0
You're welcome
NB:- If you require colours Cyan, Green, Cyan then use code below:-
Code:
[COLOR=navy]Sub[/COLOR] MG02Nov17
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, ac [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] R [COLOR=navy]As[/COLOR] Range, col [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Range("B6", Range("B" & Rows.Count).End(xlUp))
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
[COLOR=navy]If[/COLOR] Dn.Offset(, 17).Value = 6 [COLOR=navy]Then[/COLOR]
    col = IIf(col = vbCyan, vbGreen, vbCyan)
    [COLOR=navy]For[/COLOR] ac = 1 To 7
        [COLOR=navy]Set[/COLOR] R = Dn.Offset(, ac + 8)
        R.Interior.Color = col
        Dn.Offset(-R + 1, ac).Resize(R).Interior.Color = col
    [COLOR=navy]Next[/COLOR] ac
[COLOR=navy]End[/COLOR] If
[COLOR=navy]Next[/COLOR] Dn
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Last edited:
Upvote 0
You're welcome
NB:- If you require colours Cyan, Green, Cyan then use code below:-
Code:
[COLOR=navy]Sub[/COLOR] MG02Nov17
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, ac [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] R [COLOR=navy]As[/COLOR] Range, col [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Range("B6", Range("B" & Rows.Count).End(xlUp))
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
[COLOR=navy]If[/COLOR] Dn.Offset(, 17).Value = 6 [COLOR=navy]Then[/COLOR]
    col = IIf(col = vbCyan, vbGreen, vbCyan)
    [COLOR=navy]For[/COLOR] ac = 1 To 7
        [COLOR=navy]Set[/COLOR] R = Dn.Offset(, ac + 8)
        R.Interior.Color = col
        Dn.Offset(-R + 1, ac).Resize(R).Interior.Color = col
    [COLOR=navy]Next[/COLOR] ac
[COLOR=navy]End[/COLOR] If
[COLOR=navy]Next[/COLOR] Dn
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
MickG, much appreciates for coding alternate colours code it is fine.

Have a nice day

Good luck!

Regards,
Moti
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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