LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Deleting rows

Thanks, Jim, but still no luck. What is most strange is I have the code
below in another sub that works fine (this one loads the selection form which
includes the code that is not working tied to a specific selection made).
I've tested to see if I'm passing the test for the first If/Then statement
and that is working but something between the For/Next statements are failing.

==================
Private Sub MeasDateMill1_Change()
'Check to see if data with same date/mill have already been entered in the
database
Dim rngA As Range
Dim dataws As Worksheet
Set dataws = Worksheets("Data")
With Worksheets("Data")
Set rngA = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
End With
'CODE TO FIND DUPLICATE DATA
For i = rngA.Count To 1 Step -1 ' Test from bottom of range to 1st row
If dataws.Cells(i, 1).Value = MeasDateMill1 And _
dataws.Cells(i, 2).Value = "Mill 1" Then
Dim ans As Long
ans = MsgBox("Measurements for this date on this mill already exist
in the Database.", vbOKOnly)
' ExistingDataFound.Show Eliminating this pop up until can figure
out how to solve problem of overwriting data
' For the time being will give a pop up only telling the user there
is data with this date in the db already
'
Mill1DuplicateFound.Show
Exit Sub
'
End If
Next i
End Sub
"Jim Rech" wrote:

Set rngA = dataws.Cells(.Rows.Count, "A").End(xlUp)


This sets a one cell range equal to the last cell in A with an entry.

You have to specifiy with the begins and ends:

Set rngA = Range(.Cells(1,1), .Cells(.Rows.Count, "A").End(xlUp))

--
Jim
"Brian" wrote in message
...
|I am trying to delete rows if column A has value X and column B has value
Y.
| My If test does not seem to be working in this particular sub (although I
| have virtually identical code in another sub that does work). I'm at a
loss.
| Code is below...
|
| If ExistingDataFound.Overwrite.Value = True Then
| Dim rngA As Range
| Dim dataws As Worksheet
| Set dataws = Worksheets("Data")
| With Worksheets("Data")
| Set rngA = dataws.Cells(.Rows.Count, "A").End(xlUp)
| End With
| 'CODE TO FIND DUPLICATE DATA
| For i = rngA.Count To 1 Step -1 ' Test from bottom of range to 1st
row
| If dataws.Cells(i, 1).Value = MeasDateMill1 And _
| dataws.Cells(i, 2).Value = "Mill 1" Then
| Rows(i).Delete Shift:=xlUp
| Unload ExistingDataFound
| Exit Sub
| End If
| Next i
| End If



 
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 for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
Help!!! I have problem deleting 2500 rows of filtered rows shirley_kee[_2_] Excel Programming 1 January 12th 06 03:15 AM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM


All times are GMT +1. The time now is 04:11 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"