PC Review


Reply
Thread Tools Rate Thread

conflict of one loop to another?

 
 
bri_lost
Guest
Posts: n/a
 
      29th Jun 2009

Hi Everybody,

I am trying to figure out why my main script can't call a second script to
run after done running without causes an error.

I would like to combine it all into one smooth continuous step but it seems
not possible here are the scripts.

Dim ycps As Range
Dim xconcen As Range
Dim element As Range
Dim slp As Double
Dim ycept As Double
Dim sample As Range
Dim myactivecell As Range

'stores active cell position
Set myactivecell = ActiveCell

'ug/l evaluation
Set ycps = Application.InputBox(Prompt:="Select counts with the
mouse(calibration y axis)", Type:=8)
Set xconcen = Application.InputBox(Prompt:="Select respective
concentrations with the mouse(calibration x axis)", Type:=8)
Set element = Application.InputBox(Prompt:="Select the element to be
calibrated with the mouse(chart title)", Type:=8)
slp = Application.WorksheetFunction.Slope(ycps, xconcen)
ycept = Application.WorksheetFunction.Intercept(ycps, xconcen)

'set up for do loop
Dim i As Integer
Dim C As Range
Set sample = ActiveCell
Set C = ActiveCell
ActiveCell.Offset(0, 1) = (sample - ycept) / slp

Do Until ActiveCell.Value = Empty
Application.ScreenUpdating = False
i = i + 1
C.Cells(i, 1).Select
Set sample = ActiveCell
C.Cells(i, 1).Offset(0, 1) = (sample - ycept) / slp
Loop


myactivecell.Activate 'returns to start activecell position

Call Blanks 'here is where the second script is called but can't run


End Sub

Public Sub Blanks()

'Blanks subtraction
Dim blks As Range
Dim blk_avg As Double
Dim ugl As Range
Set blks = Application.InputBox(Prompt:="Select blanks with the
mouse(blank average)", Type:=8)

ActiveCell.EntireColumn.Offset(0, 2).Insert
blk_avg = Application.WorksheetFunction.Average(blks)

With ActiveCell
.Offset(-1, 1) = blk_avg
.Offset(-1, 0) = "Blank Avg"
.Offset(-2, 1) = "ug/l"
.Offset(-2, 2) = "ug/l - Blank"
End With


Set ugl = ActiveCell.Offset(0, 1)
ActiveCell.Offset(0, 2) = ugl - blk_avg

Dim z As Integer
Dim B As Range
Set B = ActiveCell
Application.ScreenUpdating = False
Do Until ActiveCell.Value = Empty
z = z + 1
B.Cells(z, 1).Select
Set ugl = ActiveCell.Offset(0, 1)
B.Cells(z, 1).Offset(0, 2) = ugl - blk_avg

Loop


End Sub


Would be really grateful for the help?

thanks,
brian

 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      29th Jun 2009

have you tried..

Sub Demo()
Call MainScript 'we don't see the heading SUB...
Call Blanks
End Sub


"bri_lost" <(E-Mail Removed)> wrote in message
news:C994F569-7848-42A6-A361-(E-Mail Removed)...
> Hi Everybody,
>
> I am trying to figure out why my main script can't call a second script to
> run after done running without causes an error.
>
> I would like to combine it all into one smooth continuous step but it
> seems
> not possible here are the scripts.
>
> Dim ycps As Range
> Dim xconcen As Range
> Dim element As Range
> Dim slp As Double
> Dim ycept As Double
> Dim sample As Range
> Dim myactivecell As Range
>
> 'stores active cell position
> Set myactivecell = ActiveCell
>
> 'ug/l evaluation
> Set ycps = Application.InputBox(Prompt:="Select counts with the
> mouse(calibration y axis)", Type:=8)
> Set xconcen = Application.InputBox(Prompt:="Select respective
> concentrations with the mouse(calibration x axis)", Type:=8)
> Set element = Application.InputBox(Prompt:="Select the element to be
> calibrated with the mouse(chart title)", Type:=8)
> slp = Application.WorksheetFunction.Slope(ycps, xconcen)
> ycept = Application.WorksheetFunction.Intercept(ycps, xconcen)
>
> 'set up for do loop
> Dim i As Integer
> Dim C As Range
> Set sample = ActiveCell
> Set C = ActiveCell
> ActiveCell.Offset(0, 1) = (sample - ycept) / slp
>
> Do Until ActiveCell.Value = Empty
> Application.ScreenUpdating = False
> i = i + 1
> C.Cells(i, 1).Select
> Set sample = ActiveCell
> C.Cells(i, 1).Offset(0, 1) = (sample - ycept) / slp
> Loop
>
>
> myactivecell.Activate 'returns to start activecell position
>
> Call Blanks 'here is where the second script is called but can't run
>
>
> End Sub
>
> Public Sub Blanks()
>
> 'Blanks subtraction
> Dim blks As Range
> Dim blk_avg As Double
> Dim ugl As Range
> Set blks = Application.InputBox(Prompt:="Select blanks with the
> mouse(blank average)", Type:=8)
>
> ActiveCell.EntireColumn.Offset(0, 2).Insert
> blk_avg = Application.WorksheetFunction.Average(blks)
>
> With ActiveCell
> .Offset(-1, 1) = blk_avg
> .Offset(-1, 0) = "Blank Avg"
> .Offset(-2, 1) = "ug/l"
> .Offset(-2, 2) = "ug/l - Blank"
> End With
>
>
> Set ugl = ActiveCell.Offset(0, 1)
> ActiveCell.Offset(0, 2) = ugl - blk_avg
>
> Dim z As Integer
> Dim B As Range
> Set B = ActiveCell
> Application.ScreenUpdating = False
> Do Until ActiveCell.Value = Empty
> z = z + 1
> B.Cells(z, 1).Select
> Set ugl = ActiveCell.Offset(0, 1)
> B.Cells(z, 1).Offset(0, 2) = ugl - blk_avg
>
> Loop
>
>
> End Sub
>
>
> Would be really grateful for the help?
>
> thanks,
> brian
>

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      29th Jun 2009

1. After the loop just before calling the procedure 'Blanks' set the screen
updating to True and try again.,
2. Place a msgbox just before calling the 'Blanks' Procedure.

'your code
Loop
Application.ScreenUpdating = True
myactivecell.Activate 'returns to start activecell position
Msgbox "Done"
Call Blanks

If this post helps click Yes
---------------
Jacob Skaria


"bri_lost" wrote:

> Hi Everybody,
>
> I am trying to figure out why my main script can't call a second script to
> run after done running without causes an error.
>
> I would like to combine it all into one smooth continuous step but it seems
> not possible here are the scripts.
>
> Dim ycps As Range
> Dim xconcen As Range
> Dim element As Range
> Dim slp As Double
> Dim ycept As Double
> Dim sample As Range
> Dim myactivecell As Range
>
> 'stores active cell position
> Set myactivecell = ActiveCell
>
> 'ug/l evaluation
> Set ycps = Application.InputBox(Prompt:="Select counts with the
> mouse(calibration y axis)", Type:=8)
> Set xconcen = Application.InputBox(Prompt:="Select respective
> concentrations with the mouse(calibration x axis)", Type:=8)
> Set element = Application.InputBox(Prompt:="Select the element to be
> calibrated with the mouse(chart title)", Type:=8)
> slp = Application.WorksheetFunction.Slope(ycps, xconcen)
> ycept = Application.WorksheetFunction.Intercept(ycps, xconcen)
>
> 'set up for do loop
> Dim i As Integer
> Dim C As Range
> Set sample = ActiveCell
> Set C = ActiveCell
> ActiveCell.Offset(0, 1) = (sample - ycept) / slp
>
> Do Until ActiveCell.Value = Empty
> Application.ScreenUpdating = False
> i = i + 1
> C.Cells(i, 1).Select
> Set sample = ActiveCell
> C.Cells(i, 1).Offset(0, 1) = (sample - ycept) / slp
> Loop
>
>
> myactivecell.Activate 'returns to start activecell position
>
> Call Blanks 'here is where the second script is called but can't run
>
>
> End Sub
>
> Public Sub Blanks()
>
> 'Blanks subtraction
> Dim blks As Range
> Dim blk_avg As Double
> Dim ugl As Range
> Set blks = Application.InputBox(Prompt:="Select blanks with the
> mouse(blank average)", Type:=8)
>
> ActiveCell.EntireColumn.Offset(0, 2).Insert
> blk_avg = Application.WorksheetFunction.Average(blks)
>
> With ActiveCell
> .Offset(-1, 1) = blk_avg
> .Offset(-1, 0) = "Blank Avg"
> .Offset(-2, 1) = "ug/l"
> .Offset(-2, 2) = "ug/l - Blank"
> End With
>
>
> Set ugl = ActiveCell.Offset(0, 1)
> ActiveCell.Offset(0, 2) = ugl - blk_avg
>
> Dim z As Integer
> Dim B As Range
> Set B = ActiveCell
> Application.ScreenUpdating = False
> Do Until ActiveCell.Value = Empty
> z = z + 1
> B.Cells(z, 1).Select
> Set ugl = ActiveCell.Offset(0, 1)
> B.Cells(z, 1).Offset(0, 2) = ugl - blk_avg
>
> Loop
>
>
> End Sub
>
>
> Would be really grateful for the help?
>
> thanks,
> brian
>

 
Reply With Quote
 
bri_lost
Guest
Posts: n/a
 
      30th Jun 2009

Hey Jacob,

Thanks a million I would have never thought that the problem lies in
screenupdating. Thanks a lot functions perfect now.
Brian

"Jacob Skaria" wrote:

> 1. After the loop just before calling the procedure 'Blanks' set the screen
> updating to True and try again.,
> 2. Place a msgbox just before calling the 'Blanks' Procedure.
>
> 'your code
> Loop
> Application.ScreenUpdating = True
> myactivecell.Activate 'returns to start activecell position
> Msgbox "Done"
> Call Blanks
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "bri_lost" wrote:
>
> > Hi Everybody,
> >
> > I am trying to figure out why my main script can't call a second script to
> > run after done running without causes an error.
> >
> > I would like to combine it all into one smooth continuous step but it seems
> > not possible here are the scripts.
> >
> > Dim ycps As Range
> > Dim xconcen As Range
> > Dim element As Range
> > Dim slp As Double
> > Dim ycept As Double
> > Dim sample As Range
> > Dim myactivecell As Range
> >
> > 'stores active cell position
> > Set myactivecell = ActiveCell
> >
> > 'ug/l evaluation
> > Set ycps = Application.InputBox(Prompt:="Select counts with the
> > mouse(calibration y axis)", Type:=8)
> > Set xconcen = Application.InputBox(Prompt:="Select respective
> > concentrations with the mouse(calibration x axis)", Type:=8)
> > Set element = Application.InputBox(Prompt:="Select the element to be
> > calibrated with the mouse(chart title)", Type:=8)
> > slp = Application.WorksheetFunction.Slope(ycps, xconcen)
> > ycept = Application.WorksheetFunction.Intercept(ycps, xconcen)
> >
> > 'set up for do loop
> > Dim i As Integer
> > Dim C As Range
> > Set sample = ActiveCell
> > Set C = ActiveCell
> > ActiveCell.Offset(0, 1) = (sample - ycept) / slp
> >
> > Do Until ActiveCell.Value = Empty
> > Application.ScreenUpdating = False
> > i = i + 1
> > C.Cells(i, 1).Select
> > Set sample = ActiveCell
> > C.Cells(i, 1).Offset(0, 1) = (sample - ycept) / slp
> > Loop
> >
> >
> > myactivecell.Activate 'returns to start activecell position
> >
> > Call Blanks 'here is where the second script is called but can't run
> >
> >
> > End Sub
> >
> > Public Sub Blanks()
> >
> > 'Blanks subtraction
> > Dim blks As Range
> > Dim blk_avg As Double
> > Dim ugl As Range
> > Set blks = Application.InputBox(Prompt:="Select blanks with the
> > mouse(blank average)", Type:=8)
> >
> > ActiveCell.EntireColumn.Offset(0, 2).Insert
> > blk_avg = Application.WorksheetFunction.Average(blks)
> >
> > With ActiveCell
> > .Offset(-1, 1) = blk_avg
> > .Offset(-1, 0) = "Blank Avg"
> > .Offset(-2, 1) = "ug/l"
> > .Offset(-2, 2) = "ug/l - Blank"
> > End With
> >
> >
> > Set ugl = ActiveCell.Offset(0, 1)
> > ActiveCell.Offset(0, 2) = ugl - blk_avg
> >
> > Dim z As Integer
> > Dim B As Range
> > Set B = ActiveCell
> > Application.ScreenUpdating = False
> > Do Until ActiveCell.Value = Empty
> > z = z + 1
> > B.Cells(z, 1).Select
> > Set ugl = ActiveCell.Offset(0, 1)
> > B.Cells(z, 1).Offset(0, 2) = ugl - blk_avg
> >
> > Loop
> >
> >
> > End Sub
> >
> >
> > Would be really grateful for the help?
> >
> > thanks,
> > brian
> >

 
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
Re: Simple window application with a loop and a button to eventuallystop the loop Joe Cool Microsoft C# .NET 15 29th Jul 2009 08:40 PM
Synchronization conflict message but no conflict table in list =?Utf-8?B?U2NhblZhY2M=?= Microsoft Access 1 28th Dec 2005 05:48 PM
XP & 2 Hard Drives Conflict? BootUp Loop CJ Windows XP General 4 17th Aug 2004 02:32 AM
Convert loop with Match function to avoid nested loop??? Kobayashi Microsoft Excel Programming 2 17th Mar 2004 06:36 PM
driver conflict with XP: possibly video? but certified.. exact conflict unknown seth thomas rasmussen Windows XP Drivers 9 8th Dec 2003 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 AM.