PC Review


Reply
Thread Tools Rate Thread

Condition prompting data incomplete

 
 
=?Utf-8?B?QWxjaGVtaXN0?=
Guest
Posts: n/a
 
      25th Aug 2007
Hi there.

I have a vlookup table and want to create a rule in the data entry sheet
(not vlookup source data) that when a Product is selected from the vlookup
dropbox (Price is included via vlkup), the user is required to enter data
into a non-vlookup cell on the same row but different column named Number. I
have no idea what to use or how to implement a formula. Oh, and how to
restrict to 4 digits only?

eg.
... | Product | Price | Number | ..
... | peas | $2 | 2007 | ..

When Peas are selected and the user moves to another row for example, you
are required to enter the Number on that row first. The number is required
before you can move to the next row.

What and how do i implement this please?
Appreciate your time.
 
Reply With Quote
 
 
 
 
Sandy Mann
Guest
Posts: n/a
 
      25th Aug 2007
Perhaps something like this event Macro in the sheet module:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
Application.EnableEvents = False
a = Application.CountA(Range("A12:A100"))
b = Application.CountA(Range("B12:B100"))
c = Application.CountA(Range("C12:C100"))

If a = b And a <> c Then
Cells(Cells(100, 1).End(xlUp).Row, 3).Select
MsgBox "Please fill in all three cells first"
End If
Application.EnableEvents = True
End Sub


and use Data Validation for the number of digits.
--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(E-Mail Removed)
Replace @mailinator.com with @tiscali.co.uk


"Alchemist" <(E-Mail Removed)> wrote in message
news:7C01E455-D7D9-4FFE-8F20-(E-Mail Removed)...
> Hi there.
>
> I have a vlookup table and want to create a rule in the data entry sheet
> (not vlookup source data) that when a Product is selected from the vlookup
> dropbox (Price is included via vlkup), the user is required to enter data
> into a non-vlookup cell on the same row but different column named Number.
> I
> have no idea what to use or how to implement a formula. Oh, and how to
> restrict to 4 digits only?
>
> eg.
> .. | Product | Price | Number | ..
> .. | peas | $2 | 2007 | ..
>
> When Peas are selected and the user moves to another row for example, you
> are required to enter the Number on that row first. The number is required
> before you can move to the next row.
>
> What and how do i implement this please?
> Appreciate your time.
>



 
Reply With Quote
 
=?Utf-8?B?QWxjaGVtaXN0?=
Guest
Posts: n/a
 
      4th Sep 2007
Hi Sandy.

I tried below without changes and immediantly I got an error:
VB Compile Error
Ambiguous name detected: Worksheet_SelectionChange

and the first line is highlighted
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range

What does this mean?

And just to make sure, column E(row 3) requires 4digits to be entered if
column C (row3) has data in it and down the page to row 40, this will work?

Thanks.


"Sandy Mann" wrote:

> Perhaps something like this event Macro in the sheet module:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
> Application.EnableEvents = False
> a = Application.CountA(Range("A12:A100"))
> b = Application.CountA(Range("B12:B100"))
> c = Application.CountA(Range("C12:C100"))
>
> If a = b And a <> c Then
> Cells(Cells(100, 1).End(xlUp).Row, 3).Select
> MsgBox "Please fill in all three cells first"
> End If
> Application.EnableEvents = True
> End Sub
>
>
> and use Data Validation for the number of digits.
> --
> HTH
>
> Sandy
> In Perth, the ancient capital of Scotland
> and the crowning place of kings
>
> (E-Mail Removed)
> Replace @mailinator.com with @tiscali.co.uk
>
>
> "Alchemist" <(E-Mail Removed)> wrote in message
> news:7C01E455-D7D9-4FFE-8F20-(E-Mail Removed)...
> > Hi there.
> >
> > I have a vlookup table and want to create a rule in the data entry sheet
> > (not vlookup source data) that when a Product is selected from the vlookup
> > dropbox (Price is included via vlkup), the user is required to enter data
> > into a non-vlookup cell on the same row but different column named Number.
> > I
> > have no idea what to use or how to implement a formula. Oh, and how to
> > restrict to 4 digits only?
> >
> > eg.
> > .. | Product | Price | Number | ..
> > .. | peas | $2 | 2007 | ..
> >
> > When Peas are selected and the user moves to another row for example, you
> > are required to enter the Number on that row first. The number is required
> > before you can move to the next row.
> >
> > What and how do i implement this please?
> > Appreciate your time.
> >

>
>
>

 
Reply With Quote
 
Sandy Mann
Guest
Posts: n/a
 
      4th Sep 2007
I see my name but I have no memory of writing that! Must be a *senior
moment* <g>

I think that the ambiguous name error will be because when you entered the
sheet module XL put the bare bones of a Worksheet_SelectionChange in for
you then you pasted my macro giving you two macros of the same name. Delete
everything in the module and paste in this one:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub

On Error GoTo GetOut

Application.EnableEvents = False
a = Application.CountA(Range("A1:A40"))
b = Application.CountA(Range("B1:B40"))
c = Application.CountA(Range("C1:C40"))

If a = b And a <> c Then
Cells(Cells(100, 1).End(xlUp).Row, 3).Select
MsgBox "Please fill in all three cells first"
End If
GetOut:
Application.EnableEvents = True
End Sub

I see in the original macro for some reason looks for data from row 12 to
100. I don't see you asking for this anywhere so I have re-written it to
look at the data in A3:C40 if that is not right then change the lines

a = Application.CountA(Range("A3:A40"))
b = Application.CountA(Range("B3:B40"))
c = Application.CountA(Range("C3:C40"))

or to whatever you data start line is in.

To ensure that they enter 4 digits select C3:C40 then select:

Data > Validation > Settings > in the Allow: box select Custom then in the
Formula: box that will appear enter the formula:

=AND(ISNUMBER(A3),LEN(A3)=4)

But either do that *before* you put the macro in or open the Workbook with
Macros disabled.

You can also add Input and Error messages.

Post back if you are still having difficulties.


--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(E-Mail Removed)
Replace @mailinator.com with @tiscali.co.uk


"Alchemist" <(E-Mail Removed)> wrote in message
news:51143BDA-9C9B-4D1C-B74D-(E-Mail Removed)...
> Hi Sandy.
>
> I tried below without changes and immediantly I got an error:
> VB Compile Error
> Ambiguous name detected: Worksheet_SelectionChange
>
> and the first line is highlighted
> Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range
>
> What does this mean?
>
> And just to make sure, column E(row 3) requires 4digits to be entered if
> column C (row3) has data in it and down the page to row 40, this will
> work?
>
> Thanks.
>
>



 
Reply With Quote
 
=?Utf-8?B?QWxjaGVtaXN0?=
Guest
Posts: n/a
 
      4th Sep 2007
There are 2 other codes in the VB sheet.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
for a vl combolist.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
forget what this was for but works.

and then yours below to complete my sheet, total 3.

I worked out the 4 digit validation after playing with it, thanks.
Interesting.
I assume your does not work because there is a title like yours already?
Maybe can join them together?

taa


"Sandy Mann" wrote:

> I see my name but I have no memory of writing that! Must be a *senior
> moment* <g>
>
> I think that the ambiguous name error will be because when you entered the
> sheet module XL put the bare bones of a Worksheet_SelectionChange in for
> you then you pasted my macro giving you two macros of the same name. Delete
> everything in the module and paste in this one:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
>
> On Error GoTo GetOut
>
> Application.EnableEvents = False
> a = Application.CountA(Range("A1:A40"))
> b = Application.CountA(Range("B1:B40"))
> c = Application.CountA(Range("C1:C40"))
>
> If a = b And a <> c Then
> Cells(Cells(100, 1).End(xlUp).Row, 3).Select
> MsgBox "Please fill in all three cells first"
> End If
> GetOut:
> Application.EnableEvents = True
> End Sub
>
> I see in the original macro for some reason looks for data from row 12 to
> 100. I don't see you asking for this anywhere so I have re-written it to
> look at the data in A3:C40 if that is not right then change the lines
>
> a = Application.CountA(Range("A3:A40"))
> b = Application.CountA(Range("B3:B40"))
> c = Application.CountA(Range("C3:C40"))
>
> or to whatever you data start line is in.
>
> To ensure that they enter 4 digits select C3:C40 then select:
>
> Data > Validation > Settings > in the Allow: box select Custom then in the
> Formula: box that will appear enter the formula:
>
> =AND(ISNUMBER(A3),LEN(A3)=4)
>
> But either do that *before* you put the macro in or open the Workbook with
> Macros disabled.
>
> You can also add Input and Error messages.
>
> Post back if you are still having difficulties.
>
>
> --
> HTH
>
> Sandy
> In Perth, the ancient capital of Scotland
> and the crowning place of kings
>
> (E-Mail Removed)
> Replace @mailinator.com with @tiscali.co.uk
>
>
> "Alchemist" <(E-Mail Removed)> wrote in message
> news:51143BDA-9C9B-4D1C-B74D-(E-Mail Removed)...
> > Hi Sandy.
> >
> > I tried below without changes and immediantly I got an error:
> > VB Compile Error
> > Ambiguous name detected: Worksheet_SelectionChange
> >
> > and the first line is highlighted
> > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range
> >
> > What does this mean?
> >
> > And just to make sure, column E(row 3) requires 4digits to be entered if
> > column C (row3) has data in it and down the page to row 40, this will
> > work?
> >
> > Thanks.
> >
> >

>
>
>

 
Reply With Quote
 
Sandy Mann
Guest
Posts: n/a
 
      4th Sep 2007
Sorry I assumed that you had no other Macros in the Workbook.

Immediately after the:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

of your existing Worksheet_SelectionChange macro add the lines:

If Not Intersect(Target, Range("A:C")) Is Nothing Then
Call FillIt
Exit Sub
End If

then in a normal module add the macro:

Sub FillIt()

a = Application.CountA(Range("A1:A100"))
b = Application.CountA(Range("B1:B100"))
c = Application.CountA(Range("C1:C100"))

If a = b And a <> c Then
Cells(Cells(100, 1).End(xlUp).Row, 3).Select
MsgBox "Please fill in all three cells first"
End If

End Sub

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(E-Mail Removed)
Replace @mailinator.com with @tiscali.co.uk


"Alchemist" <(E-Mail Removed)> wrote in message
news:7BAFD798-C6D0-46F1-BA7C-(E-Mail Removed)...
> There are 2 other codes in the VB sheet.
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
> Cancel As Boolean)
> for a vl combolist.
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> forget what this was for but works.
>
> and then yours below to complete my sheet, total 3.
>
> I worked out the 4 digit validation after playing with it, thanks.
> Interesting.
> I assume your does not work because there is a title like yours already?
> Maybe can join them together?
>
> taa
>
>
> "Sandy Mann" wrote:
>
>> I see my name but I have no memory of writing that! Must be a *senior
>> moment* <g>
>>
>> I think that the ambiguous name error will be because when you entered
>> the
>> sheet module XL put the bare bones of a Worksheet_SelectionChange in for
>> you then you pasted my macro giving you two macros of the same name.
>> Delete
>> everything in the module and paste in this one:
>>
>> Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
>> If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
>>
>> On Error GoTo GetOut
>>
>> Application.EnableEvents = False
>> a = Application.CountA(Range("A1:A40"))
>> b = Application.CountA(Range("B1:B40"))
>> c = Application.CountA(Range("C1:C40"))
>>
>> If a = b And a <> c Then
>> Cells(Cells(100, 1).End(xlUp).Row, 3).Select
>> MsgBox "Please fill in all three cells first"
>> End If
>> GetOut:
>> Application.EnableEvents = True
>> End Sub
>>
>> I see in the original macro for some reason looks for data from row 12 to
>> 100. I don't see you asking for this anywhere so I have re-written it to
>> look at the data in A3:C40 if that is not right then change the lines
>>
>> a = Application.CountA(Range("A3:A40"))
>> b = Application.CountA(Range("B3:B40"))
>> c = Application.CountA(Range("C3:C40"))
>>
>> or to whatever you data start line is in.
>>
>> To ensure that they enter 4 digits select C3:C40 then select:
>>
>> Data > Validation > Settings > in the Allow: box select Custom then in
>> the
>> Formula: box that will appear enter the formula:
>>
>> =AND(ISNUMBER(A3),LEN(A3)=4)
>>
>> But either do that *before* you put the macro in or open the Workbook
>> with
>> Macros disabled.
>>
>> You can also add Input and Error messages.
>>
>> Post back if you are still having difficulties.
>>
>>
>> --
>> HTH
>>
>> Sandy
>> In Perth, the ancient capital of Scotland
>> and the crowning place of kings
>>
>> (E-Mail Removed)
>> Replace @mailinator.com with @tiscali.co.uk
>>
>>
>> "Alchemist" <(E-Mail Removed)> wrote in message
>> news:51143BDA-9C9B-4D1C-B74D-(E-Mail Removed)...
>> > Hi Sandy.
>> >
>> > I tried below without changes and immediantly I got an error:
>> > VB Compile Error
>> > Ambiguous name detected: Worksheet_SelectionChange
>> >
>> > and the first line is highlighted
>> > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range
>> >
>> > What does this mean?
>> >
>> > And just to make sure, column E(row 3) requires 4digits to be entered
>> > if
>> > column C (row3) has data in it and down the page to row 40, this will
>> > work?
>> >
>> > Thanks.
>> >
>> >

>>
>>
>>

>



 
Reply With Quote
 
=?Utf-8?B?QWxjaGVtaXN0?=
Guest
Posts: n/a
 
      4th Sep 2007
It doesn't want to work it seems.
Here's the code I found on the forums that does it's job:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Application.EnableEvents = False
Application.ScreenUpdating = True

Set cboTemp = ws.OLEObjects("Products")
On Error Resume Next
With cboTemp
.Top = 10
.Left = 10
.Width = 0
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
.Value = ""
End With

errHandler:
Application.EnableEvents = True
Exit Sub

If Not Intersect(Target, Range("A:C")) Is Nothing Then
Call FillIt
Exit Sub
End If

End Sub

I pasted the IF range as is as above after the byVal Target As Range but
didn't work so I tried at the bottom. In the module, I pasted the Sub FillIt
and of course appeared in the macros under the Tools Menu. Saved the editor
and closed it, saved the xl file, then tried to use the code as above and
nothing happened using

Sub FillIt()

a = Application.CountA(Range("C3:C40"))
b = Application.CountA(Range("D340"))
c = Application.CountA(Range("E3:E40"))

If a = b And a <> c Then
Cells(Cells(100, 1).End(xlUp).Row, 3).Select
MsgBox "It is a requirement to fill in column E to continue"
End If

End Sub




"Alchemist" wrote:

> There are 2 other codes in the VB sheet.
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
> Cancel As Boolean)
> for a vl combolist.
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> forget what this was for but works.
>
> and then yours below to complete my sheet, total 3.
>
> I worked out the 4 digit validation after playing with it, thanks.
> Interesting.
> I assume your does not work because there is a title like yours already?
> Maybe can join them together?
>
> taa
>
>
> "Sandy Mann" wrote:
>
> > I see my name but I have no memory of writing that! Must be a *senior
> > moment* <g>
> >
> > I think that the ambiguous name error will be because when you entered the
> > sheet module XL put the bare bones of a Worksheet_SelectionChange in for
> > you then you pasted my macro giving you two macros of the same name. Delete
> > everything in the module and paste in this one:
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> > If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
> >
> > On Error GoTo GetOut
> >
> > Application.EnableEvents = False
> > a = Application.CountA(Range("A1:A40"))
> > b = Application.CountA(Range("B1:B40"))
> > c = Application.CountA(Range("C1:C40"))
> >
> > If a = b And a <> c Then
> > Cells(Cells(100, 1).End(xlUp).Row, 3).Select
> > MsgBox "Please fill in all three cells first"
> > End If
> > GetOut:
> > Application.EnableEvents = True
> > End Sub
> >
> > I see in the original macro for some reason looks for data from row 12 to
> > 100. I don't see you asking for this anywhere so I have re-written it to
> > look at the data in A3:C40 if that is not right then change the lines
> >
> > a = Application.CountA(Range("A3:A40"))
> > b = Application.CountA(Range("B3:B40"))
> > c = Application.CountA(Range("C3:C40"))
> >
> > or to whatever you data start line is in.
> >
> > To ensure that they enter 4 digits select C3:C40 then select:
> >
> > Data > Validation > Settings > in the Allow: box select Custom then in the
> > Formula: box that will appear enter the formula:
> >
> > =AND(ISNUMBER(A3),LEN(A3)=4)
> >
> > But either do that *before* you put the macro in or open the Workbook with
> > Macros disabled.
> >
> > You can also add Input and Error messages.
> >
> > Post back if you are still having difficulties.
> >
> >
> > --
> > HTH
> >
> > Sandy
> > In Perth, the ancient capital of Scotland
> > and the crowning place of kings
> >
> > (E-Mail Removed)
> > Replace @mailinator.com with @tiscali.co.uk
> >
> >
> > "Alchemist" <(E-Mail Removed)> wrote in message
> > news:51143BDA-9C9B-4D1C-B74D-(E-Mail Removed)...
> > > Hi Sandy.
> > >
> > > I tried below without changes and immediantly I got an error:
> > > VB Compile Error
> > > Ambiguous name detected: Worksheet_SelectionChange
> > >
> > > and the first line is highlighted
> > > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range
> > >
> > > What does this mean?
> > >
> > > And just to make sure, column E(row 3) requires 4digits to be entered if
> > > column C (row3) has data in it and down the page to row 40, this will
> > > work?
> > >
> > > Thanks.
> > >
> > >

> >
> >
> >

 
Reply With Quote
 
Sandy Mann
Guest
Posts: n/a
 
      4th Sep 2007
I don't know why it didn't work you you unless you were you got an error
when the EnableEvents was set to false. your original code has a label:
"errHandler but there is no On Error GoTo errHandler referring to it. To
make sure that Events are enabled either close and then re-open the workbook
or put this small macro in a normal module and run it:

Sub GetGoing()
Application.EnableEvents = True
End Sub

This code worked for me and shouldn't stop your original code running:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a As Integer
Dim b As Integer
Dim c As Integer

If Intersect(Target, Range("A3:B40")) Is Nothing Then GoTo YourMacro
a = Application.CountA(Range("A1:A100"))
b = Application.CountA(Range("B1:B100"))
c = Application.CountA(Range("C1:C100"))

If a = b And a <> c Then
Cells(Cells(100, 1).End(xlUp).Row, 3).Select
MsgBox "Please fill in all three cells first"
Exit Sub
End If


YourMacro:
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Application.EnableEvents = False
Application.ScreenUpdating = True

On Error GoTo errHandler
Set cboTemp = ws.OLEObjects("Products")
On Error Resume Next
With cboTemp
.Top = 10
.Left = 10
.Width = 0
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
.Value = ""
End With

errHandler:
Application.EnableEvents = True

End Sub

In actual fact the original code errored out for me at the line:
Set cboTemp = ws.OLEObjects("Products")

so I added the On Error GoTo errHandler line to get around that. If you
don't need it you can just delete it again.

The FillIt sub is no longer needed so you can delete that as well.


--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(E-Mail Removed)
Replace @mailinator.com with @tiscali.co.uk


"Alchemist" <(E-Mail Removed)> wrote in message
news:C88ABA4E-DD61-42FC-B64F-(E-Mail Removed)...
> It doesn't want to work it seems.
> Here's the code I found on the forums that does it's job:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> Dim str As String
> Dim cboTemp As OLEObject
> Dim ws As Worksheet
> Set ws = ActiveSheet
> Application.EnableEvents = False
> Application.ScreenUpdating = True
>
> Set cboTemp = ws.OLEObjects("Products")
> On Error Resume Next
> With cboTemp
> .Top = 10
> .Left = 10
> .Width = 0
> .ListFillRange = ""
> .LinkedCell = ""
> .Visible = False
> .Value = ""
> End With
>
> errHandler:
> Application.EnableEvents = True
> Exit Sub
>
> If Not Intersect(Target, Range("A:C")) Is Nothing Then
> Call FillIt
> Exit Sub
> End If
>
> End Sub
>
> I pasted the IF range as is as above after the byVal Target As Range but
> didn't work so I tried at the bottom. In the module, I pasted the Sub
> FillIt
> and of course appeared in the macros under the Tools Menu. Saved the
> editor
> and closed it, saved the xl file, then tried to use the code as above and
> nothing happened using
>
> Sub FillIt()
>
> a = Application.CountA(Range("C3:C40"))
> b = Application.CountA(Range("D340"))
> c = Application.CountA(Range("E3:E40"))
>
> If a = b And a <> c Then
> Cells(Cells(100, 1).End(xlUp).Row, 3).Select
> MsgBox "It is a requirement to fill in column E to
> continue"
> End If
>
> End Sub
>
>
>
>
> "Alchemist" wrote:
>
>> There are 2 other codes in the VB sheet.
>>
>> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
>> Cancel As Boolean)
>> for a vl combolist.
>>
>> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>> forget what this was for but works.
>>
>> and then yours below to complete my sheet, total 3.
>>
>> I worked out the 4 digit validation after playing with it, thanks.
>> Interesting.
>> I assume your does not work because there is a title like yours already?
>> Maybe can join them together?
>>
>> taa
>>
>>
>> "Sandy Mann" wrote:
>>
>> > I see my name but I have no memory of writing that! Must be a *senior
>> > moment* <g>
>> >
>> > I think that the ambiguous name error will be because when you entered
>> > the
>> > sheet module XL put the bare bones of a Worksheet_SelectionChange in
>> > for
>> > you then you pasted my macro giving you two macros of the same name.
>> > Delete
>> > everything in the module and paste in this one:
>> >
>> > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
>> > If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
>> >
>> > On Error GoTo GetOut
>> >
>> > Application.EnableEvents = False
>> > a = Application.CountA(Range("A1:A40"))
>> > b = Application.CountA(Range("B1:B40"))
>> > c = Application.CountA(Range("C1:C40"))
>> >
>> > If a = b And a <> c Then
>> > Cells(Cells(100, 1).End(xlUp).Row, 3).Select
>> > MsgBox "Please fill in all three cells first"
>> > End If
>> > GetOut:
>> > Application.EnableEvents = True
>> > End Sub
>> >
>> > I see in the original macro for some reason looks for data from row 12
>> > to
>> > 100. I don't see you asking for this anywhere so I have re-written it
>> > to
>> > look at the data in A3:C40 if that is not right then change the lines
>> >
>> > a = Application.CountA(Range("A3:A40"))
>> > b = Application.CountA(Range("B3:B40"))
>> > c = Application.CountA(Range("C3:C40"))
>> >
>> > or to whatever you data start line is in.
>> >
>> > To ensure that they enter 4 digits select C3:C40 then select:
>> >
>> > Data > Validation > Settings > in the Allow: box select Custom then in
>> > the
>> > Formula: box that will appear enter the formula:
>> >
>> > =AND(ISNUMBER(A3),LEN(A3)=4)
>> >
>> > But either do that *before* you put the macro in or open the Workbook
>> > with
>> > Macros disabled.
>> >
>> > You can also add Input and Error messages.
>> >
>> > Post back if you are still having difficulties.
>> >
>> >
>> > --
>> > HTH
>> >
>> > Sandy
>> > In Perth, the ancient capital of Scotland
>> > and the crowning place of kings
>> >
>> > (E-Mail Removed)
>> > Replace @mailinator.com with @tiscali.co.uk
>> >
>> >
>> > "Alchemist" <(E-Mail Removed)> wrote in message
>> > news:51143BDA-9C9B-4D1C-B74D-(E-Mail Removed)...
>> > > Hi Sandy.
>> > >
>> > > I tried below without changes and immediantly I got an error:
>> > > VB Compile Error
>> > > Ambiguous name detected: Worksheet_SelectionChange
>> > >
>> > > and the first line is highlighted
>> > > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range
>> > >
>> > > What does this mean?
>> > >
>> > > And just to make sure, column E(row 3) requires 4digits to be entered
>> > > if
>> > > column C (row3) has data in it and down the page to row 40, this will
>> > > work?
>> > >
>> > > Thanks.
>> > >
>> > >
>> >
>> >
>> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling: When adding data where data is incomplete/incorrect. Rob W Microsoft Access 2 20th Feb 2008 11:27 PM
incomplete data showing rameshjha Microsoft C# .NET 0 20th Jun 2006 12:13 PM
Prompting users to import data =?Utf-8?B?RGlhbW9uZER1Zw==?= Microsoft Access 3 3rd Jun 2005 12:52 PM
Prompting to allow External Query Data Refresh =?Utf-8?B?VGltIEJha2Vy?= Microsoft Excel Misc 3 8th Mar 2005 11:29 AM
Prompting Criteria Data Jay Klaver Microsoft Access Queries 1 26th Sep 2003 10:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:29 AM.