Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-13-2014, 07:35 AM
EC37 EC37 is offline NEWB to Macros - formatting exports Windows 7 64bit NEWB to Macros - formatting exports Office 2010 64bit
Advanced Beginner
NEWB to Macros - formatting exports
 
Join Date: May 2014
Location: Waltham, MA
Posts: 56
EC37 is on a distinguished road
Default

OK, so, lots to take in and I appreciate your help..

I feel stupid by asking what you mean by 'static' when referring to the ranges. The ranges do look a bit odd, but that is because first, I filtered the rows to only show me the rows identified as "Header". However, we can't simply color based on that information- because Header not only identifies the Phases, but sub-phases as well. It is something I can certainly change, now that i Think of it- to make the code a bit easier to write. We could simply color cells based on the words "Phase" and "Sub-Phase" in column L. Phase is one color, sub-phase is another.

Without getting too far off topic from your response- I will try to de-code in my own dumbed down version of what I'm looking at .
First delete the identified columns.
Second, you're identifiying the ranges that need to be colored in it's own subroutine(?).
Third, you're then telling the program what to do with that subroutine once selected, and to color it based on the value of X (Select Case Rng("C1").Value
Case "X": ). Although, I don't quite understand the "C1" here. Is that identifying the column? or specifically cell C1??
Fourth, in the event value of Y is found, it would color it accordingly.
And lastly, end code

If that is at all incorrect, then you can ignore the rest of this (or continue reading because I'm going to incorporate my initial suggestion from above!).

Instead of selecting several ranges, what if I were to just identify 1 range (the table). Say, cells A1:L264 (I forget the exact range, I don't have the sheet open because it's at work and i don't have VPN access ). So it would read as-

Sub Main()
Range("E:E,G:G,J:J").Delete Shift:=xlToLeft
Color Range ("A1:L264")
End Sub

' Color the supplied range.
Sub Color(Rng)


Then, tell it to look in column L, and color based on Value Case "Phase". Then, tell it to color the second piece based on Value Case "Sub-Phase".



So:

Select Case Rng("L1").Value
Case "Phase": With Rng.Interior
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0.799981688894314
End With
Case "Sub-Phase": With Rng.Interior
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
End With
Case Else:
End Select
End Sub


Am I at all correct in interpreting the code and applying it in the above?
Reply With Quote
  #2  
Old 06-13-2014, 08:15 PM
BobBridges's Avatar
BobBridges BobBridges is offline NEWB to Macros - formatting exports Windows 7 64bit NEWB to Macros - formatting exports Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

"Static" can be a technical term in VBA, but I was using it informally; I meant that the size and location of your ranges will be the same for weeks or months at a time. When I write an Excel program, usually before it can get down to work it has to identify the rows I want to process, for example by finding out which rows have "Total:" in column A, or by looking in a column for a change from one area code changes from one to the next. In your case, if I understand you, you don't have to do that—you can count on processing the same set of rows—they remain "static", in other words, without changing. Oh, they might change at some point, but seldom enough that if they do you can just go into your program and change the code. The opposite of "static" in this sense would be "dynamic", which would mean the they change a lot.

Now about your idea for working with just one range instead of a bunch: What I thought was happening (but I knew I might be wrong) is that you had some specific ranges that you wanted to color according to column C in the first row of each range. (That's why I talked in the subroutine about "C1".) But from your new proposal, it sounds like what you may want to do is color each row—each row in the whole range—based on a value in that one row. Is that right?

Like this: look at L1 and color that whole row based on whether L1 contains "Phase" or "Sub-Phase". Then color row 2 based on the contents of L2, and row 3 based on L3, and so on down to the end.

Is that right? If so it makes the job simpler—but if I'm wrong, we can still do it. I just have to be sure I understand what you need to accomplish.

That's very often the longest part of the job, by the way.

Also by the way, another time if you have to ask a question like this, it may save some time, yours as well as mine, if you post an actual workbook with either real or sample data, and a demonstration of the result that you want.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting contents after Tab of continuous lines or formatting specific area of word pawii Word 1 05-12-2014 05:24 AM
macros stebrownsword Word VBA 0 08-28-2013 01:16 AM
NEWB to Macros - formatting exports How to do Formatting Using Macros anju16saini Word VBA 1 03-11-2013 04:15 AM
NEWB to Macros - formatting exports Formatting with macros WaltR Word VBA 8 05-15-2012 06:28 PM
Macros nore Outlook 0 06-01-2011 04:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:07 AM.


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