Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default VBA Help Please (delete row)

In a previous post Don Guillett helped me and provided the following code. I
need to change this macro, but don't have a clue how. Hoping you can help.

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
End Sub

There are lines in my sheet now that have a designation (ColA) that I need
to delete when this macro runs. In the example below I'm focusing on the two
"panelboard" lines. Take a look and let me know if you know how to solve
this issue. ??? .EntireRow.Delete ???

Below is an example

What I have now:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
1 Box
1 Trim
BBB 2 Panelboard Type Q
1 Box
1 Trim
1 Ground Bar

What it looks like after macro above runs:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
AAA 4 Box
AAA 4 Trim
BBB 2 Panelboard Type Q
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar

What I need to end up with:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Box
AAA 4 Trim
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Help Please (delete row)

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
for i = lr - 1 to 2 step -1
if cells(i,1) < cells(i-1,1) and _
not isempty(cells(i-1,1) ) and _
cells(i,1) = cells(i+1,1)then
rows(i).Delete
end if
Next
End sub

--
Regards,
Tom Ogilvy





"Scott Wagner" wrote in message
...
In a previous post Don Guillett helped me and provided the following code.

I
need to change this macro, but don't have a clue how. Hoping you can

help.

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
End Sub

There are lines in my sheet now that have a designation (ColA) that I need
to delete when this macro runs. In the example below I'm focusing on the

two
"panelboard" lines. Take a look and let me know if you know how to solve
this issue. ??? .EntireRow.Delete ???

Below is an example

What I have now:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
1 Box
1 Trim
BBB 2 Panelboard Type Q
1 Box
1 Trim
1 Ground Bar

What it looks like after macro above runs:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
AAA 4 Box
AAA 4 Trim
BBB 2 Panelboard Type Q
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar

What I need to end up with:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Box
AAA 4 Trim
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default VBA Help Please (delete row)

Tom,

It skiped the first line I was hoping to delete (panelboard AAA), and
deleted one I was hoping not to delete (starter). Any ideas?

This is what it produced:
ColA ColB ColC ColD
3 XFMR Dry Type
AAA 4 Panelboard Type B
AAA 4 Box
AAA 4 Trim
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar


"Tom Ogilvy" wrote:

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
for i = lr - 1 to 2 step -1
if cells(i,1) < cells(i-1,1) and _
not isempty(cells(i-1,1) ) and _
cells(i,1) = cells(i+1,1)then
rows(i).Delete
end if
Next
End sub

--
Regards,
Tom Ogilvy





"Scott Wagner" wrote in message
...
In a previous post Don Guillett helped me and provided the following code.

I
need to change this macro, but don't have a clue how. Hoping you can

help.

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
End Sub

There are lines in my sheet now that have a designation (ColA) that I need
to delete when this macro runs. In the example below I'm focusing on the

two
"panelboard" lines. Take a look and let me know if you know how to solve
this issue. ??? .EntireRow.Delete ???

Below is an example

What I have now:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
1 Box
1 Trim
BBB 2 Panelboard Type Q
1 Box
1 Trim
1 Ground Bar

What it looks like after macro above runs:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
AAA 4 Box
AAA 4 Trim
BBB 2 Panelboard Type Q
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar

What I need to end up with:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Box
AAA 4 Trim
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Help Please (delete row)

I can't reproduce the "starter" row being deleted. is the word starter in
C3


In any event, try this:

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
for i = lr - 1 to 3 step -1
if cells(i,1) < cells(i-1,1) and _
cells(i,1) = cells(i+1,1)then
rows(i).Delete
end if
Next
End sub

change the 3 in for i = lr - 1 to 3 step -1

to reflect the first row you want checked.

--
Regards,
Tom Ogilvy







"Scott Wagner" wrote in message
...
Tom,

It skiped the first line I was hoping to delete (panelboard AAA), and
deleted one I was hoping not to delete (starter). Any ideas?

This is what it produced:
ColA ColB ColC ColD
3 XFMR Dry Type
AAA 4 Panelboard Type B
AAA 4 Box
AAA 4 Trim
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar


"Tom Ogilvy" wrote:

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
for i = lr - 1 to 2 step -1
if cells(i,1) < cells(i-1,1) and _
not isempty(cells(i-1,1) ) and _
cells(i,1) = cells(i+1,1)then
rows(i).Delete
end if
Next
End sub

--
Regards,
Tom Ogilvy





"Scott Wagner" wrote in message
...
In a previous post Don Guillett helped me and provided the following

code.
I
need to change this macro, but don't have a clue how. Hoping you can

help.

Sub fillinblanksN()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For Each c In Range("d2:d" & lr)
If Len(c) < 2 Then
c.Offset(0, -3) = c.Offset(-1, -3)
c.Offset(0, -2) = c.Offset(-1, -2)
End If
Next
End Sub

There are lines in my sheet now that have a designation (ColA) that I

need
to delete when this macro runs. In the example below I'm focusing on

the
two
"panelboard" lines. Take a look and let me know if you know how to

solve
this issue. ??? .EntireRow.Delete ???

Below is an example

What I have now:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
1 Box
1 Trim
BBB 2 Panelboard Type Q
1 Box
1 Trim
1 Ground Bar

What it looks like after macro above runs:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Panelboard Type B
AAA 4 Box
AAA 4 Trim
BBB 2 Panelboard Type Q
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar

What I need to end up with:
ColA ColB ColC ColD
1 Starter Open Type
3 XFMR Dry Type
AAA 4 Box
AAA 4 Trim
BBB 2 Box
BBB 2 Trim
BBB 2 Ground Bar






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default VBA Help Please (delete row)

That worked. Starter was in cell C2.

Thank you sir!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:16 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:54 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"