PC Review


Reply
Thread Tools Rate Thread

A basic VB script--help the newbie?

 
 
comp.databases.pick
Guest
Posts: n/a
 
      30th Jul 2007
Hi,

I think I got the wrong books for learning how to program in VBA...

I need to do the following:

if cell below current cell has the same value
and the three cells to the right of the cell below current cell have
no value
delete entire row of the cell below the current cell
repeat until different value in next cell down found

EX:

11FF07 54.90 58.90 64.23
11FF07 (blank) (blank) (blank)
11FF07 (blank) (blank) (blank)
11C 56.98 123.34 57.78

So this macro/script would see that the next 11FF07 down has no prices
(blank values) in the three cells next to it, and delete that row, and
continue down, see that the next 11FF07 down has no value either,
delete that row, continue down, and notice the next cell contains a
different value and stop.

Can anyone help with this? This isn't something I can figure out how
to "tell" the macro recorder to do with actions.

Thanks,
Gabe

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      30th Jul 2007
Gabe,

Here's one way. Make sure you backup your file first just in case it doesn't
do what you want. The script will work from bottom to top. Check if the
value in the current cell is equal to the one above. If yes, it checks if
the 3 cells to the right are blank. If yes, the entire row is deleted.

Sub test()
Dim lRow As Long
Dim lLastRow As Long

lLastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row

For lRow = lLastRow To 2 Step -1
With Range("A" & lRow)
If .Value = .Offset(-1, 0).Value Then
If .Offset(0, 1).Value & .Offset(0, 2) & .Offset(0, 3) = ""
Then
.EntireRow.Delete
End If
End If
End With
Next lRow

End Sub

--
Hope that helps.

Vergel Adriano


"comp.databases.pick" wrote:

> Hi,
>
> I think I got the wrong books for learning how to program in VBA...
>
> I need to do the following:
>
> if cell below current cell has the same value
> and the three cells to the right of the cell below current cell have
> no value
> delete entire row of the cell below the current cell
> repeat until different value in next cell down found
>
> EX:
>
> 11FF07 54.90 58.90 64.23
> 11FF07 (blank) (blank) (blank)
> 11FF07 (blank) (blank) (blank)
> 11C 56.98 123.34 57.78
>
> So this macro/script would see that the next 11FF07 down has no prices
> (blank values) in the three cells next to it, and delete that row, and
> continue down, see that the next 11FF07 down has no value either,
> delete that row, continue down, and notice the next cell contains a
> different value and stop.
>
> Can anyone help with this? This isn't something I can figure out how
> to "tell" the macro recorder to do with actions.
>
> Thanks,
> Gabe
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Script and Visual Basic 6 Code difference? =?Utf-8?B?Qmx1ZVVua25vd24=?= Microsoft Access VBA Modules 0 7th Oct 2005 01:58 PM
Newbie: Help with basic SQL steve Microsoft Access Queries 4 5th Apr 2005 05:11 PM
Code for in visual basic dotnet for a newbie in visual basic 6 =?Utf-8?B?WWFzc2VyaQ==?= Microsoft VB .NET 3 9th Oct 2004 11:26 AM
NEWBIE BASIC ????? VIC Scanners 6 24th Feb 2004 04:16 PM
Newbie to OOP needs basic help Ivan Weiss Microsoft VB .NET 7 27th Dec 2003 08:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:24 AM.