View Single Post
 
Old 07-15-2014, 09:03 AM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

The way you describe this, E, it isn't the basic statements that bother you but the structure; you're not sure how to go about it. Now, the way I'd go about it may not be the way you would. In programming there are always a lot of ways to do a task. But here's how I'd structure the logic, written not in VBA but in pseudo-code:
Code:
'I don't trust myself not to make mistakes.
copy the "Export" worksheet to a new one, and switch to the new sheet for all subsequent commands.

insert new column at C and title it "Sub-Phase".
rz = the last row '14 in your case
for jr = 2 to rz
  select case value-in-column-G 'was col F in original worksheet
    case "Phase"
      do nothing just yet
    case "Sub-Phase" 
      save value from col D
    case else
      set col C to the saved value
    end select
  next jr

' Now delete the rows you no longer want.
for jr 1 rz to 2 step -1
  select case value-in-col-G
    case "Phase": Delete row
    case "Sub-Phase": Delete row
    case else: 'no action
    end select
  next jr
Maybe it's obvious to you why I'm doing the second look backward (from rz to 2 instead of from 2 to rz); if not, ask. And I'm leaving out all sorts of details, like how to copy a worksheet and how to save a value. Ask anything you need to; but just now I'm trying to explain one way of building the program generally speaking. If I've answered on the wrong level—if you knew all that but were asking (for example) what the syntax of the statement would be to save a value—let me know.
Reply With Quote