Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default VBA code to delete rows

I have an excel worksheet ("Orders") that is linked to another worksheet
("Master Orders"). What I want to do is create a command button on my
worksheet ("Orders") that will refresh the links as well as delete any rows
on my worksheet ("Orders") that have the word "Closed" in column B. Can
anyone shed some light on how I would write this code?

Thanks
SS
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default VBA code to delete rows

Squirrel

Don't know what "refresh the links" means but for the second part.......

Sub delete_closed()
Dim C As Range
With ThisWorkbook.Sheets("Orders")
With Columns("B")
Do
Set C = .Find("Closed", LookIn:=xlValues, LookAt:=xlWhole, _
MatchCase:=False)
If C Is Nothing Then Exit Do
C.EntireRow.Delete
Loop
End With
End With
End Sub


Gord Dibben MS Excel MVP

On Sat, 20 Jan 2007 20:34:00 -0800, Secret Squirrel
wrote:

I have an excel worksheet ("Orders") that is linked to another worksheet
("Master Orders"). What I want to do is create a command button on my
worksheet ("Orders") that will refresh the links as well as delete any rows
on my worksheet ("Orders") that have the word "Closed" in column B. Can
anyone shed some light on how I would write this code?

Thanks
SS


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default VBA code to delete rows

Gord,
Thanks for your help!
The "refresh the links" means that I want to update the links that I have to
another file by just pushing a command button. If the data in the other file
is changed and a user has this file open then I want them to be able to click
a button to see if any of the data has changed in the other file. Hope that
makes better sense.

SS

"Gord Dibben" wrote:

Squirrel

Don't know what "refresh the links" means but for the second part.......

Sub delete_closed()
Dim C As Range
With ThisWorkbook.Sheets("Orders")
With Columns("B")
Do
Set C = .Find("Closed", LookIn:=xlValues, LookAt:=xlWhole, _
MatchCase:=False)
If C Is Nothing Then Exit Do
C.EntireRow.Delete
Loop
End With
End With
End Sub


Gord Dibben MS Excel MVP

On Sat, 20 Jan 2007 20:34:00 -0800, Secret Squirrel
wrote:

I have an excel worksheet ("Orders") that is linked to another worksheet
("Master Orders"). What I want to do is create a command button on my
worksheet ("Orders") that will refresh the links as well as delete any rows
on my worksheet ("Orders") that have the word "Closed" in column B. Can
anyone shed some light on how I would write this code?

Thanks
SS



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VBA code to delete rows

If the other file is changed AND saved, then you could use this kind of code to
update all the links.

Option Explicit
Private Sub CommandButton1_Click()
With Me.Parent 'thisworkbook
.UpdateLink Name:=.LinkSources
End With
End Sub

I used a commandbutton from the control toolbox toolbar.


Secret Squirrel wrote:

Gord,
Thanks for your help!
The "refresh the links" means that I want to update the links that I have to
another file by just pushing a command button. If the data in the other file
is changed and a user has this file open then I want them to be able to click
a button to see if any of the data has changed in the other file. Hope that
makes better sense.

SS

"Gord Dibben" wrote:

Squirrel

Don't know what "refresh the links" means but for the second part.......

Sub delete_closed()
Dim C As Range
With ThisWorkbook.Sheets("Orders")
With Columns("B")
Do
Set C = .Find("Closed", LookIn:=xlValues, LookAt:=xlWhole, _
MatchCase:=False)
If C Is Nothing Then Exit Do
C.EntireRow.Delete
Loop
End With
End With
End Sub


Gord Dibben MS Excel MVP

On Sat, 20 Jan 2007 20:34:00 -0800, Secret Squirrel
wrote:

I have an excel worksheet ("Orders") that is linked to another worksheet
("Master Orders"). What I want to do is create a command button on my
worksheet ("Orders") that will refresh the links as well as delete any rows
on my worksheet ("Orders") that have the word "Closed" in column B. Can
anyone shed some light on how I would write this code?

Thanks
SS




--

Dave Peterson
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
Can I delete blank rows from excel without selecting them? rgtest Excel Worksheet Functions 9 February 14th 09 03:12 PM
delete rows Jack Sons Excel Discussion (Misc queries) 5 November 22nd 05 04:30 PM
How can we delete rows permanently from excel sheet Nehal Shah Excel Discussion (Misc queries) 1 August 1st 05 01:58 PM
code to delete rows ianalexh Excel Discussion (Misc queries) 5 May 5th 05 10:46 AM
Insert rows Mr. G. Excel Worksheet Functions 3 March 31st 05 03:49 AM


All times are GMT +1. The time now is 01:06 PM.

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

About Us

"It's about Microsoft Excel"