PC Review


Reply
Thread Tools Rate Thread

Auto refresh for VB script to take effect.

 
 
=?Utf-8?B?UmFqdWxh?=
Guest
Posts: n/a
 
      12th Oct 2006
I have the following VB script which changes the color of the cell based on
its
value.
When the value changes, the color doesn't change at the moment. I need to
double click on the cell, for the color to change.
How can i make it refresh automatically? Is there a problem with the code?

This is my code.

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A1:AQ120")) Is Nothing Then
Select Case Target

Case Is = "A"
icolor = 38
Case Is = "B"
icolor = 38
Case Is = "C"
icolor = 35
Case Is = "D"
icolor = 36
Case Is = "E"
icolor = 39
Case Is = "F"
icolor = 35
Case Is = "G"
icolor = 37
Case Is = "H"
icolor = 34
Case Is = "I"
icolor = 40
Case Is = "J"
icolor = 40
Case Is = "K"
icolor = 34
Case Is = "L"
icolor = 34
Case Is = "M"
icolor = 34
Case Else
'Whatever
End Select

Target.Interior.ColorIndex = icolor
End If

End Sub

 
Reply With Quote
 
 
 
 
Carim
Guest
Posts: n/a
 
      12th Oct 2006
Hi,

Try following to correct :
Application.EnableEvents = True

HTH
Cheers
Carim

 
Reply With Quote
 
=?Utf-8?B?UmFqdWxh?=
Guest
Posts: n/a
 
      12th Oct 2006
Hi,

Where do i need to put this? In the code or as a seperate button??

Regads


"Carim" wrote:

> Hi,
>
> Try following to correct :
> Application.EnableEvents = True
>
> HTH
> Cheers
> Carim
>
>

 
Reply With Quote
 
Carim
Guest
Posts: n/a
 
      12th Oct 2006
In a separate macro, just to reinitiate your excel ...

As a matter of fact, your macro has always worked ... but an incident
has very recently occured, while debuging another macro... for example
.... it is this incident which has interrupted the EnableEvents mode ...

HTH
Carim

 
Reply With Quote
 
WhytheQ
Guest
Posts: n/a
 
      12th Oct 2006
A good place to put that line is in an auto exec macro like:

'========================
Sub Auto_Open()
Application.EnableEvents = True
End Sub
========================

....the above will fire when the workbook is opened on any other user's
machine.
Rgds
J


Carim wrote:
> In a separate macro, just to reinitiate your excel ...
>
> As a matter of fact, your macro has always worked ... but an incident
> has very recently occured, while debuging another macro... for example
> ... it is this incident which has interrupted the EnableEvents mode ...
>
> HTH
> Carim


 
Reply With Quote
 
=?Utf-8?B?UmFqdWxh?=
Guest
Posts: n/a
 
      12th Oct 2006
sorry to say, but nothing seems to be working. Any other smart option?

"WhytheQ" wrote:

> A good place to put that line is in an auto exec macro like:
>
> '========================
> Sub Auto_Open()
> Application.EnableEvents = True
> End Sub
> ========================
>
> ....the above will fire when the workbook is opened on any other user's
> machine.
> Rgds
> J
>
>
> Carim wrote:
> > In a separate macro, just to reinitiate your excel ...
> >
> > As a matter of fact, your macro has always worked ... but an incident
> > has very recently occured, while debuging another macro... for example
> > ... it is this incident which has interrupted the EnableEvents mode ...
> >
> > HTH
> > Carim

>
>

 
Reply With Quote
 
Carim
Guest
Posts: n/a
 
      12th Oct 2006
Close Excel and re-open it ...

Carim

 
Reply With Quote
 
=?Utf-8?B?UmFqdWxh?=
Guest
Posts: n/a
 
      13th Oct 2006
I did a real stupid code. Just recorded a macro for double clicking the cells
with look-up. And then copied the code for other cells. Now i run this macro
to refresh.
IS there a easier or smaller code to replace this. This code is really STUPID.

Sub Refresh()
'
' Refresh Macro
' Macro recorded 13/10/2006 by XXX
'

'
Range("C6").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
Range("C11").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
Range("C1124").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
Range("C29").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"

End Sub

"Carim" wrote:

> Close Excel and re-open it ...
>
> Carim
>
>

 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      15th Oct 2006
Sub Refresh()

Range("C6,C11,C1124,C29").FormulaR1C1 = _
"=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
End Sub

--
Regards,
Tom Ogilvy


"Rajula" <(E-Mail Removed)> wrote in message
news:A06C777B-E35D-48D3-BEA4-(E-Mail Removed)...
>I did a real stupid code. Just recorded a macro for double clicking the
>cells
> with look-up. And then copied the code for other cells. Now i run this
> macro
> to refresh.
> IS there a easier or smaller code to replace this. This code is really
> STUPID.
>
> Sub Refresh()
> '
> ' Refresh Macro
> ' Macro recorded 13/10/2006 by XXX
> '
>
> '
> Range("C6").Select
> ActiveCell.FormulaR1C1 = _
> "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> Range("C11").Select
> ActiveCell.FormulaR1C1 = _
> "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> Range("C1124").Select
> ActiveCell.FormulaR1C1 = _
> "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> Range("C29").Select
> ActiveCell.FormulaR1C1 = _
> "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
>
> End Sub
>
> "Carim" wrote:
>
>> Close Excel and re-open it ...
>>
>> Carim
>>
>>



 
Reply With Quote
 
=?Utf-8?B?UmFqdWxh?=
Guest
Posts: n/a
 
      16th Oct 2006
I have around 200 cells in the range, not just the 4.
Any other solution.

"Tom Ogilvy" wrote:

> Sub Refresh()
>
> Range("C6,C11,C1124,C29").FormulaR1C1 = _
> "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Rajula" <(E-Mail Removed)> wrote in message
> news:A06C777B-E35D-48D3-BEA4-(E-Mail Removed)...
> >I did a real stupid code. Just recorded a macro for double clicking the
> >cells
> > with look-up. And then copied the code for other cells. Now i run this
> > macro
> > to refresh.
> > IS there a easier or smaller code to replace this. This code is really
> > STUPID.
> >
> > Sub Refresh()
> > '
> > ' Refresh Macro
> > ' Macro recorded 13/10/2006 by XXX
> > '
> >
> > '
> > Range("C6").Select
> > ActiveCell.FormulaR1C1 = _
> > "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> > Range("C11").Select
> > ActiveCell.FormulaR1C1 = _
> > "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> > Range("C1124").Select
> > ActiveCell.FormulaR1C1 = _
> > "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> > Range("C29").Select
> > ActiveCell.FormulaR1C1 = _
> > "=VLOOKUP(R[-3]C,'Desk Allocation'!R2C3:R130C6,2,FALSE)"
> >
> > End Sub
> >
> > "Carim" wrote:
> >
> >> Close Excel and re-open it ...
> >>
> >> Carim
> >>
> >>

>
>
>

 
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
Copy Excel functions formula and auto refresh refresh Pauline Cheong Microsoft Excel Worksheet Functions 3 16th Feb 2009 01:23 AM
browser refresh effect on session variables and view state? =?Utf-8?B?RGFiYmxlcg==?= Microsoft ASP .NET 1 8th Aug 2006 01:46 AM
Rollover Script with Sound Effect (Malfunction) =?Utf-8?B?QmFtbSBCYW1t?= Windows XP Internet Explorer 1 7th Nov 2004 06:38 PM
Re: Pivot Table Auto Refresh and Auto Flow to columns Frank Kabel Microsoft Excel Misc 0 27th Jul 2004 07:29 PM
Pivot table refresh - how do you stop auto-refresh? bscruggs@microsoft.com Microsoft Excel Misc 1 21st Feb 2004 12:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:04 AM.