Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default ERROR 400 on identical codes different range

Code 1 works fine on A, B, C, D.

With identical data in H, I, J, K code 2 errors.

What the @#$% am I overlooking?

Thanks,
Howard

Option Explicit

Sub MyDupesGone1()

With Sheets("Sheet4").Range("A1", Range("D1").End(xlDown))
.RemoveDuplicates Columns:=Array(1, 2, 3, 4), _
Header:=xlNo
End With
End Sub


Sub MyDupesGone2()

With Sheets("Sheet4").Range("H1", Range("K1").End(xlDown))
.RemoveDuplicates Columns:=Array(8, 9, 10, 11), _
Header:=xlNo
End With
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default ERROR 400 on identical codes different range

Hi Howard,

Am Wed, 26 Nov 2014 23:30:04 -0800 (PST) schrieb L. Howard:

With identical data in H, I, J, K code 2 errors.


if your range is H":K & lrow
you also have to write Array (1, 2, 3, 4)
The columns in the array refer to the first column in the range and that
is column H

Sub MyDupesGone2()
With Sheets("Sheet4").Range("H1", Range("K1").End(xlDown))
.RemoveDuplicates Columns:=Array(1, 2, 3, 4), _
Header:=xlNo
End With
End Sub

Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default ERROR 400 on identical codes different range

On Wednesday, November 26, 2014 11:58:52 PM UTC-8, Claus Busch wrote:
Hi Howard,

Am Wed, 26 Nov 2014 23:30:04 -0800 (PST) schrieb L. Howard:

With identical data in H, I, J, K code 2 errors.


if your range is H":K & lrow
you also have to write Array (1, 2, 3, 4)
The columns in the array refer to the first column in the range and that
is column H

Sub MyDupesGone2()
With Sheets("Sheet4").Range("H1", Range("K1").End(xlDown))
.RemoveDuplicates Columns:=Array(1, 2, 3, 4), _
Header:=xlNo
End With
End Sub

Regards
Claus B.



OBoy! They are the elements NOT the column Headers/numbers!


Thanks for your patience.

Howard
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default ERROR 400 on identical codes different range

On Thursday, November 27, 2014 1:30:14 AM UTC-6, L. Howard wrote:
Code 1 works fine on A, B, C, D.

With identical data in H, I, J, K code 2 errors.

What the @#$% am I overlooking?

Thanks,
Howard

Option Explicit

Sub MyDupesGone1()

With Sheets("Sheet4").Range("A1", Range("D1").End(xlDown))
.RemoveDuplicates Columns:=Array(1, 2, 3, 4), _
Header:=xlNo
End With
End Sub


Sub MyDupesGone2()

With Sheets("Sheet4").Range("H1", Range("K1").End(xlDown))
.RemoveDuplicates Columns:=Array(8, 9, 10, 11), _
Header:=xlNo
End With
End Sub


Did not test but wonder if this would not work using a1 for last row

With Sheets("Sheet4").Range("A1", Range("a1").End(xlDown))
.RemoveDuplicates Columns:=Array(1,2,3,4,8,9,10,11, _
Header:=xlNo
End With




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default ERROR 400 on identical codes different range

Did not test but wonder if this would not work using a1 for last row

This has been thoroughly tested and works a peach for me to find the
last row/col that contains data...

Public Function GetLastDataPos&(Optional Wks As Worksheet, _
Optional IsRow As Boolean = True, Optional StartPos& = 1)
' Finds the last row or col of UsedRange that contains data.
' Allows for excluding any number of header rows/cols.
'
' Args:
' Wks Optional:
' Object ref to the sheet being searched.
' Defaults to ActiveSheet if missing.
'
' IsRow Optional:
' Boolean value that determines which axis to test.
'
' StartPos Optional:
' A type Long that specifies the start row/col of the
search.
' If omitted the search starts at A1.
'

Dim n&, k&, lLast&

If Wks Is Nothing Then Set Wks = ActiveSheet

With Wks.UsedRange
lLast = IIf(IsRow, .Rows.Count, .Columns.Count)
For n = lLast To StartPos Step -1
k = Application.CountA(IIf(IsRow, Wks.Rows(n), Wks.Columns(n)))
If k 0 Then GetLastDataPos = n: Exit Function
Next 'n
End With 'Wks.UsedRange
End Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default ERROR 400 on identical codes different range

Hi Garry,

Can you give me a simple example of how to use the function?

I start by copying to a standard module... then what do I do on the sheet?

Howard
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default ERROR 400 on identical codes different range

Hi Garry,

Can you give me a simple example of how to use the function?

I start by copying to a standard module... then what do I do on the
sheet?

Howard


It's this simple...

Dim lLastRow&, lLastCol&, lNextRow&, lNextCol&

lLastRow = GetLastDataPos() 'to return row#
lLastCol = GetLastDataPos(IsRow:=False) 'to return col#

OR

LNextRow = GetLastDataPos() + 1
LNextCol = GetLastDataPos(IsRow:=False) + 1

...where any extra blank rows residual in UsedRange doesn't matter
because the function loops backwards until it finds a non-empty range.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 852
Default ERROR 400 on identical codes different range

On Thursday, November 27, 2014 9:46:51 AM UTC-8, GS wrote:
Hi Garry,

Can you give me a simple example of how to use the function?

I start by copying to a standard module... then what do I do on the
sheet?

Howard


It's this simple...

Dim lLastRow&, lLastCol&, lNextRow&, lNextCol&

lLastRow = GetLastDataPos() 'to return row#
lLastCol = GetLastDataPos(IsRow:=False) 'to return col#

OR

LNextRow = GetLastDataPos() + 1
LNextCol = GetLastDataPos(IsRow:=False) + 1

..where any extra blank rows residual in UsedRange doesn't matter
because the function loops backwards until it finds a non-empty range.

--
Garry


Okay, thanks.

Off to play with it.

Howard
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default ERROR 400 on identical codes different range

But have some fun, eh!!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
identical formula returns #VALUE! error Tasso Excel Discussion (Misc queries) 3 June 1st 09 04:57 PM
Series with named range on several identical sheets caroline Charts and Charting in Excel 5 January 30th 08 03:33 AM
How to lookup when range contains multiple identical entries? Doug Laidlaw Excel Discussion (Misc queries) 1 January 19th 06 12:18 PM
Inexplicable difference in row hiding speed - identical code, identical machines! Matt Larkin Excel Programming 5 November 1st 04 10:35 AM
how do i get an error message if identical data is in two or more. bobone Excel Programming 2 September 5th 04 09:49 AM


All times are GMT +1. The time now is 08:01 AM.

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"