Re: delete rows
- From: "Bob Phillips" <bob.NGs@xxxxxxxxxxxxx>
- Date: Mon, 9 Oct 2006 11:10:38 +0100
I would add a button to the menu, like this
'If you put code in the appropriate workbook open event, and
'delete it in the close it will exist only for that workbook.
'Here is an example of a building a commandbar on the fly
'when you open a workbook. It adds a sub-menu to the Tools menu.
Option Explicit
Private Sub Workbook_Open()
Dim oCb As CommandBar
Dim oCtl As CommandBarPopup
Dim oCtlBtn As CommandBarButton
On Error Resume Next
Application.CommandBars("Work*** Menu
Bar").Controls("myMacroButton").Delete
On Erroro GoTo 0
Set oCb = Application.CommandBars("Work*** Menu Bar")
With oCb
Set oCtlBtn = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtlBtn.Caption = "myMacroButton"
oCtlBtn.FaceId = 161
oCtlBtn.OnAction = "myMacro"
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCb As CommandBar
Set oCb = Application.CommandBars("Work*** Menu Bar")
oCb.Controls("myMacroButton").Delete
End Sub
'To add this, go to the VB IDE (ALT-F11 from Excel), and in
'the explorer pane, select your workbook. Then select the
'ThisWorkbook object (it's in Microsoft Excel Objects which
'might need expanding). Double-click the ThisWorkbook and
'a code window will open up. Copy this code into there,
'changing the caption and action to suit.
'This is part of the workbook, and will only exist with the
'workbook, but will be available to anyone who opens the
'workbook.
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"massi" <massi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9738BE94-2BF8-425C-9CDA-3F3F28F6550D@xxxxxxxxxxxxxxxx
installation is ok. I have it now in the addins list available but i don'topen
know how to use it. should i have a short cut in the menu or something?
what i want is: a have a few files where i want to run my macro. at the
moment i created an empty file with the macro and i keep it open. the i
the other files when needed and i run the macro from the 1st file.it,
can i make the addin work like this?
"Bob Phillips" wrote:
You then distribute the addin to the other desktops, and they install
manageTools>Addins>Browse
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"massi" <massi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0CD651BD-4FDA-416A-99BE-2E03F3AE02FB@xxxxxxxxxxxxxxxx
Hi Bob,
good afternoon,
I have creeated the addin no problem but how do i use it?
sorry but this is all new for me...
Massimo
"Bob Phillips" wrote:
Look at creating an addin.
http://support.microsoft.com/default.aspx?kbid=211563
How to create an add-in file in Excel 2000
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"massi" <massi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:86FA77A1-3A77-41E5-B28D-8EF93F08151D@xxxxxxxxxxxxxxxx
I couldn't reply earlier as I had the i-net down. At the end I
'---------------------------------------------------------------------------to
find
a solution.:
'---------------------------------------------------------------------------with----------------
' this part transform the links in normal test and substitute #N/A
blank cell
Operation:=xlNone,----------------
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues,
LookAt:=xlPart, _SkipBlanks _
:=False, Transpose:=False
Columns("B:B").Select
Selection.Replace What:="#N/A", Replacement:="",
SearchFormat:=False,SearchOrder:=xlByRows, MatchCase:=False,
done at_
firstReplaceFormat:=False
End Sub
'--------------------------------------------------------
'and this one remove all the blank cells
'--------------------------------------------------------
Sub Macro02()
Dim Rng As Range, Rng1 As Range
Set Rng = Range("b1:b10000") '<<====== CHANGE to suit
On Error Resume Next
Set Rng1 = Intersect(Rng, _
Columns("B:B").SpecialCells(xlBlanks))
On Error GoTo 0
If Not Rng1 Is Nothing Then Rng1.EntireRow.Delete
End Sub
it might not be a masterpiece of VB but it works fine. It was the
time
I putting my hands on a macro...
now I need to apply this macro to different files. What I have
finerthe
files Imoment is:
I have a blank excel file with the macro recorded. Then I open the
need to work on and I run the macro from tools/macro. Is there a
withway
to
make this macro working for the files? Other people should work
thethis
file and I was hoping to find a better solution.
cheers
Thanks for your help
"Sandy" wrote:
I agree with you Bob, yours code is def the one to go with...
Sandy
Bob Phillips wrote:
Public Sub Tester02()
Dim Rng As Range, Rng1 As Range
For i = 10000 To 7 Step -1
If IsError(Cells(i, "B")) Then
If Rng1 Is Nothing Then
Set Rng1 = Rows(i)
Else
Set Rng1 = Union(Rng1, Rows(i))
End If
End If
Next i
If Not Rng1 Is Nothing Then Rng1.Delete
End Sub
I think Sandy's doesn't work because he is going top-down, and
direct)pointers
get out of sync, which is why I went bottom up.
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing
itunfortuantely
"massi" <massi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DCBED91C-1BD9-47DE-9F12-9E68D6F145CD@xxxxxxxxxxxxxxxx
I have tried both of the methods that you have suggested but
no
one works.
The one from Bob returns me Compile Error: Syntax error and
somegets
stuck
while the one.
and yours it works only partially, meaning that it deletes
information irows
but
not
all and it deletes also the ones with the relevant
saywant to
keep.
any idea why?
thank you
"Sandy" wrote:
This one will work too...
Sub DeleteRow()
Dim MyCell As Range
On Error Resume Next
For Each MyCell In Range("B1:B10000")
If CVErr(MyCell) = CVErr(xlErrNA) Then
MyCell.EntireRow.Delete
End If
DoEvents
Next MyCell
End Sub
Sandy
massi wrote:
Hi,
I need a macro that check the values of a column (let's
"#N/A"B)
which
has
links to another ***. in case the cell is equal to
b10000I
below)want to
delete
the whole row.
I have a macro that works fine if the cell is empty (see
:
'=======================
Public Sub Tester02()
Dim Rng As Range, Rng1 As Range
Set Rng = Range("b7:b10000") '<<====== from b7 to
is
On Error Resume Next
Set Rng1 = Intersect(Rng, _
Columns("B:B").SpecialCells(xlBlanks))
On Error GoTo 0
If Not Rng1 Is Nothing Then Rng1.EntireRow.Delete
End Sub
'<<=======================
I have tried this one below but it doesn't work.
'=======================
Public Sub Delete_empty()
If IsError(.Cells(Lrow, "b").Value) Then
'Do nothing, This avoid a error if there
Valuea
error in
the
.Rows(Lrow).Deletecell
ElseIf .Cells(Lrow, "b").Value = "#N/A" Then
'This will delete each row with the
"ron"
in
Column A,
case sensitive.
End If
End Sub
'<<=======================
any suggestion?
thankx
.
- Follow-Ups:
- Re: delete rows
- From: massi
- Re: delete rows
- From: massi
- Re: delete rows
- References:
- Re: delete rows
- From: Sandy
- Re: delete rows
- From: massi
- Re: delete rows
- From: Bob Phillips
- Re: delete rows
- From: Sandy
- Re: delete rows
- From: massi
- Re: delete rows
- From: Bob Phillips
- Re: delete rows
- From: massi
- Re: delete rows
- From: Bob Phillips
- Re: delete rows
- From: massi
- Re: delete rows
- Prev by Date: Re: delete rows
- Next by Date: Re: Convert Numbers
- Previous by thread: Re: delete rows
- Next by thread: Re: delete rows
- Index(es):