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: 161
Default strange behaviour

Hi,

I have a fairly complex workbook (that is being used as a database) whichis
exhibiting some strange behaviour.

The user enters a new record from a form that is called from a button click.
When the form is closed, the data is copied to pre-defined places on another
sheet. New lines are then created on several other sheets (all hidden) so
that various automated analyses can be carried out on the newly entered data.
The creation of these new lines includes adding some quite complex formulas
into some cells and adding data validation and conditional formatting to
others.

Each of these activities is done by a different sub called from the input
form.

When I run the various subs, they work perfectly - each sheet is set up
exactly as iI want it to be. However, when I try to run the whole lot
together most (but not all!) of the formatting in each of the subs fails. No
error messages are generated

The full code is large and complicated, so it wouldn't be appropriate to
post much of it here, but below is the bit that calls the subs from the form:
<some code here
Set CurrentCell = CurrentCell.Offset(0, 4) ' response approach
CurrentCell.Value = ComboBox2.Value

New_Storage ' create storage area on history page

Date_New_Risk_Line ' date stamp the new line and add the unique
identifier

Format_New_Risk_Line ' format the new risk line

add_new_control_line ' update controls page with the new risk

add_new_mitigation_line ' update mitigations page

add_contingency ' update contingency page

add_new_assessment_line ' update the risk assessment page with the
new risk

<some more code here

This is the first bit of code of one of the subs (they are all pretty
similar and all the variables are declared earlier) :

Sheets("Treatment - Controls").Unprotect
Set vNewRisk = Sheets("Treatment - Controls").Range("a8")
lLineCount = 8
Do Until vNewRisk.Value = "" ' look for first
blank cell
Set vNewRisk = vNewRisk.Offset(1, 0)
lLineCount = lLineCount + 1
Loop

sRiskNumber = Sheets("user data").Range("b7")
Set rLookUpRange = Sheets("identification").Range("a:d")
With vNewRisk ' put new risk
number into first blank line & format cell
.Value = sRiskNumber
.Interior.ColorIndex = 15
.Borders.LineStyle = xlContinuous
.Locked = True
End With
vTitle = Application.VLookup(sRiskNumber, rLookUpRange, 4)
Set vNewRisk = vNewRisk.Offset(0, 1)
With vNewRisk ' put new risk
title into first blank line & format cell
.Value = vTitle
.Interior.ColorIndex = 15
.Borders.LineStyle = xlContinuous
.WrapText = True
.Locked = True
End With

' put borders around cells
Sheets("Treatment - Controls").Range("a" & lLineCount & ":r" &
lLineCount).Select
With Selection
.Borders.LineStyle = xlContinuous
End With

The first couple of parts work ('Look for the first blank cell' and 'put new
risk number...'), but the vlookup does not work (I'd appreciate it if someone
could explain why not) and the formatting of the borders around a selection
of cells also does not work.

It's probably worth emphasising that this whole sub does work when run as a
standalone piece of code.

This is all in Office '07 under Vista, if that makes a difference.

My apologies for the length of this post and please let me know if I need to
provide more information.

TIA

Dave
 
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
Strange if(***) behaviour? Excel 2003 - SPB Excel Discussion (Misc queries) 6 August 6th 06 05:34 PM
Strange VBA Behaviour Ricko Excel Programming 0 July 28th 05 07:53 AM
Strange behaviour Edgar Thoemmes Excel Worksheet Functions 1 February 8th 05 03:20 PM
Strange behaviour in VBA Help Michael Singmin Excel Programming 4 June 4th 04 07:06 PM
strange behaviour Patrick Molloy Excel Programming 0 September 4th 03 07:51 AM


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