Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Is Indexing Possible in VBA/Excel?

Hello!

I'm having trouble with an Excel/VBA problem. I've created a spreadsheet which has a User Interface created in VBA.

I want the user to select 3 fields (on the form) which are unique each time. The fields a

Station
Year
Period

There can't be duplicate combinations of these values. I know how to do this in Access, but don't want to re-program everythin got operate there.

Can anyone suggest how this is done in Excel with VBA? I feel like I've been going round in circles, so any help would be greatly appreciated!

Thanks,
Stan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Is Indexing Possible in VBA/Excel?

Stan,

As there is a user interface via the form, I assume you are saving the
values?

One way to test would be to use the worksheetfunction COUNTIF to see if the
value already exists.. For instance, assume that you save these 3 fields in
columns A, B, C in a worksheet, you then use code like this to test

Dim cRows As Long

With Worksheets("Sheet1")
cRows = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("D1").Formula = "=A1&B1&C1"
.Range("D1").AutoFill Destination:=.Range("D1:D" & cRows)
If WorksheetFunction.CountIf(.Range("D1:D" & cRows), "abc") 0 Then
MsgBox "Already used"
End If
End With

Change the value abc for the concatenated values just entered. You could
even create the concatenated value in column D as you save the 3 values,
avoiding the autofill.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stan" wrote in message
...
Hello!

I'm having trouble with an Excel/VBA problem. I've created a spreadsheet

which has a User Interface created in VBA.

I want the user to select 3 fields (on the form) which are unique each

time. The fields a

Station
Year
Period

There can't be duplicate combinations of these values. I know how to do

this in Access, but don't want to re-program everythin got operate there.

Can anyone suggest how this is done in Excel with VBA? I feel like I've

been going round in circles, so any help would be greatly appreciated!

Thanks,
Stan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Is Indexing Possible in VBA/Excel?

Cheers Bob, that's great.

I'll give it a bash and should i have any more probs, I'll be back here!

Thanks again!

S

"Bob Phillips" wrote:

Stan,

As there is a user interface via the form, I assume you are saving the
values?

One way to test would be to use the worksheetfunction COUNTIF to see if the
value already exists.. For instance, assume that you save these 3 fields in
columns A, B, C in a worksheet, you then use code like this to test

Dim cRows As Long

With Worksheets("Sheet1")
cRows = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("D1").Formula = "=A1&B1&C1"
.Range("D1").AutoFill Destination:=.Range("D1:D" & cRows)
If WorksheetFunction.CountIf(.Range("D1:D" & cRows), "abc") 0 Then
MsgBox "Already used"
End If
End With

Change the value abc for the concatenated values just entered. You could
even create the concatenated value in column D as you save the 3 values,
avoiding the autofill.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Stan" wrote in message
...
Hello!

I'm having trouble with an Excel/VBA problem. I've created a spreadsheet

which has a User Interface created in VBA.

I want the user to select 3 fields (on the form) which are unique each

time. The fields a

Station
Year
Period

There can't be duplicate combinations of these values. I know how to do

this in Access, but don't want to re-program everythin got operate there.

Can anyone suggest how this is done in Excel with VBA? I feel like I've

been going round in circles, so any help would be greatly appreciated!

Thanks,
Stan




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
Indexing Anto111 Excel Discussion (Misc queries) 1 July 26th 08 08:01 PM
Tab indexing ibgolfn Excel Discussion (Misc queries) 2 January 16th 08 12:04 AM
Excel Indexing Function MCDST070-271 Excel Worksheet Functions 0 June 29th 06 08:50 PM
Indexing a row ecohen1 Excel Worksheet Functions 6 July 20th 05 06:11 PM
Vlookup and Indexing in excel CLSCHWIES Excel Worksheet Functions 2 December 4th 04 01:57 AM


All times are GMT +1. The time now is 02:11 PM.

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"