View Single Post
  #4   Report Post  
ksquirt ksquirt is offline
Junior Member
 
Posts: 9
Question

After more searching thru this site and others here is my current piece of the macro. The problem I'm running into now is that I need certain cell removed. Right now it's removing the whole column. How do I get it to just remove the 'dollars' for the rows with 21050 in column D? and the 'hours'for all other rows? See attached spreadsheet.

Dim LSearchRow As Integer
LSearchRow = 6


While Len(Range("A" & CStr(LSearchRow)).Value) 0

'If Column D = "90601", copy entire row
If Range("D" & CStr(LSearchRow)).Value = "90601" Then
Range("D" & CStr(LSearchRow)).EntireRow.Copy
'Insert copied Row below the original
Range("D" & CStr(LSearchRow)).EntireRow.Insert Shift:=xlDown
'Change values in Columns D on new row to 20150
Range("D" & CStr(LSearchRow + 1)) = "20150"

End If


'If Column D = "20150", remove dollars columns
If Range("D" & CStr(LSearchRow)).Value = "20150" Then
Range("G:G,I:I,K:K,M:M,O:O,Q:Q,S:S,U:U,W:W,Y:Y,AA: AA,AC:AC,AE:AE,AG:AG,AI:AI,AK:AK,AM:AM,AO:AO,AQ:AQ ,AS:AS,AU:AU,AW:AW,AY:AY").Cell.Delete

'Selection.Delete Shift:=xlToLeft
End If
'If Column D does not equal "20150", remove hours columns (*using ' to get part of the code to not work while I focus on other parts*)
'If Range("D" & CStr(LSearchRow)).Value < "20150" Then
' Range("F:F,H:H,J:J,L:L,N:N,P:P,R:R,T:T,V:V,X:X,Z:Z ,AB:AB,AD:AD,AF:AF,AH:AH,AJ:AJ,AL:AL,AN:AN,AP:AP,A R:AR,AT:AT,AV:AV,AX:AX,AZ:AZ").Select
' Selection.Delete Shift:=xlToLeft

'End If
'Increment Search row variable
LSearchRow = LSearchRow + 1

'Loop
Wend

Last edited by ksquirt : July 17th 12 at 03:14 PM