Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 06-16-2014, 10:33 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

Charles is right, EC: I'm used to writing in another language that allows concatenations merely by sticking variables and constants next to each other (eg
Code:
"A"jr":L"jr
In VBA that must be
Code:
"A" & jr & ":L" & jr
...but I left out one of the ampersands. I'd like to tell myself this is good, that you'll benefit from seeing another's errors and working out the solution, but the fact is there was nothing to keep me from testing it for simple syntax errors before I showed it to you, just in case...because simple syntax errors are so very common.

Oh, wait, I have a better excuse than I remembered: Two of my sons showed up unannounced to take me out to a sports bar and watch the first US game (against Ghana) in the World Cup for my 60th birthday. So I was sort of in a hurry to finish my response and send it to you. The US won, too!

Still, I apologize. To make it up to you, I have tested the remaining program, even though it's 'way past my bedtime (sigh, moan, and a surreptitious glance to see whether I'm making an impression) and watched it work for real. I ran it straight off the sample you sent, and therefore some parts had to be changed to match the current columns, so it looks like this:
Code:
Sub Main()
  'Range("E:E,G:G,J:J").Delete Shift:=xlToLeft
  For jr = 2 To 264
    Set org = Range("A" & jr & ":O" & jr).Interior
    Select Case Range("O" & jr).Value
      Case "Phase"
        org.ThemeColor = xlThemeColorLight2
        org.TintAndShade = 0.799981688894314
      Case "Sub-Phase"
        org.ThemeColor = xlThemeColorDark1
        org.TintAndShade = -4.99893185216834E-02
      Case Else
      End Select
    Next jr
  End Sub
(The apostrophe in the second line marks the rest of the line as a comment, which the VBA language will ignore until I take it out again.) Now, my excuses and failures aside, you really should be learning something from each mistake I make. In this case, the '&' operator in VBA is used to concatenate character strings; I momentarily thought I was writing in REXX instead of in VBA and left one out, which is why Excel balked at running it, but Charles had no difficulty figuring it out. He knows VBA and you don't, so I don't blame you for asking for help—help that you shouldn't have needed from me had I done my job right—but I do want you to understand what happened for next time. Questions?

And if it works this time, the next task is to teach the program to find the last row, so you don't have to make it run from 2 to 264 but can make it smarter.
Reply With Quote
 



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 04:52 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