Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Run Time Error 1004

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run Time Error 1004

Are you getting to Row 65536? Excel 2003 will only go to 65536. Can you
tell me which line is highlighted in excel when the failure occurs.

"Paul" wrote:

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Run Time Error 1004

Hi,

It gets to row 60289 and pastes value half way across the row and then stops
and come up with the debug error message.

When i hover over the yellow highlighted code in the de bug window the value
says -4163 as a negative.

Hope this helps as I am stuck to know what the issue is??

Thanks

Paul

"Joel" wrote:

Are you getting to Row 65536? Excel 2003 will only go to 65536. Can you
tell me which line is highlighted in excel when the failure occurs.

"Paul" wrote:

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run Time Error 1004

Which line of code is highlighted in yellow?????

"Paul" wrote:

Hi,

It gets to row 60289 and pastes value half way across the row and then stops
and come up with the debug error message.

When i hover over the yellow highlighted code in the de bug window the value
says -4163 as a negative.

Hope this helps as I am stuck to know what the issue is??

Thanks

Paul

"Joel" wrote:

Are you getting to Row 65536? Excel 2003 will only go to 65536. Can you
tell me which line is highlighted in excel when the failure occurs.

"Paul" wrote:

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Run Time Error 1004

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Hi,

It's the bottom row in the above:-

Selection.PasteSpecial Paste:=xlPasteValues

Thanks

Paul




"Joel" wrote:

Which line of code is highlighted in yellow?????

"Paul" wrote:

Hi,

It gets to row 60289 and pastes value half way across the row and then stops
and come up with the debug error message.

When i hover over the yellow highlighted code in the de bug window the value
says -4163 as a negative.

Hope this helps as I am stuck to know what the issue is??

Thanks

Paul

"Joel" wrote:

Are you getting to Row 65536? Excel 2003 will only go to 65536. Can you
tell me which line is highlighted in excel when the failure occurs.

"Paul" wrote:

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run Time Error 1004

When you hover over the line you said you get -4163. You must be reading the
value of counter. Because counter is only getting incremented it must be
wrapping because it is getting to 4095 and incrementing by one and becoming
negative. This is an indication that "counter" is only being treated as an
integer. Declare Counter as Double (or long if double doesn't work).

"Paul" wrote:

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Hi,

It's the bottom row in the above:-

Selection.PasteSpecial Paste:=xlPasteValues

Thanks

Paul




"Joel" wrote:

Which line of code is highlighted in yellow?????

"Paul" wrote:

Hi,

It gets to row 60289 and pastes value half way across the row and then stops
and come up with the debug error message.

When i hover over the yellow highlighted code in the de bug window the value
says -4163 as a negative.

Hope this helps as I am stuck to know what the issue is??

Thanks

Paul

"Joel" wrote:

Are you getting to Row 65536? Excel 2003 will only go to 65536. Can you
tell me which line is highlighted in excel when the failure occurs.

"Paul" wrote:

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Run Time Error 1004

I dimmed my counter variable as long but its still falling over in the same
place.

The counter gets to 285 out of 300 I am asking it to get to??

Thanks

Paul

"Joel" wrote:

When you hover over the line you said you get -4163. You must be reading the
value of counter. Because counter is only getting incremented it must be
wrapping because it is getting to 4095 and incrementing by one and becoming
negative. This is an indication that "counter" is only being treated as an
integer. Declare Counter as Double (or long if double doesn't work).

"Paul" wrote:

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Hi,

It's the bottom row in the above:-

Selection.PasteSpecial Paste:=xlPasteValues

Thanks

Paul




"Joel" wrote:

Which line of code is highlighted in yellow?????

"Paul" wrote:

Hi,

It gets to row 60289 and pastes value half way across the row and then stops
and come up with the debug error message.

When i hover over the yellow highlighted code in the de bug window the value
says -4163 as a negative.

Hope this helps as I am stuck to know what the issue is??

Thanks

Paul

"Joel" wrote:

Are you getting to Row 65536? Excel 2003 will only go to 65536. Can you
tell me which line is highlighted in excel when the failure occurs.

"Paul" wrote:

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Run Time Error 1004

You are now getting a different failure. It is a large area. I don't have
excel 2007 so I'm not sure what the limits are. I would try manually doing
the same operations on the worksheet and see if you get an error.

Highlight L60289:ANP60289

Then Copy and PasteSpecial with values and see if you get an error.

"Paul" wrote:

I dimmed my counter variable as long but its still falling over in the same
place.

The counter gets to 285 out of 300 I am asking it to get to??

Thanks

Paul

"Joel" wrote:

When you hover over the line you said you get -4163. You must be reading the
value of counter. Because counter is only getting incremented it must be
wrapping because it is getting to 4095 and incrementing by one and becoming
negative. This is an indication that "counter" is only being treated as an
integer. Declare Counter as Double (or long if double doesn't work).

"Paul" wrote:

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Hi,

It's the bottom row in the above:-

Selection.PasteSpecial Paste:=xlPasteValues

Thanks

Paul




"Joel" wrote:

Which line of code is highlighted in yellow?????

"Paul" wrote:

Hi,

It gets to row 60289 and pastes value half way across the row and then stops
and come up with the debug error message.

When i hover over the yellow highlighted code in the de bug window the value
says -4163 as a negative.

Hope this helps as I am stuck to know what the issue is??

Thanks

Paul

"Joel" wrote:

Are you getting to Row 65536? Excel 2003 will only go to 65536. Can you
tell me which line is highlighted in excel when the failure occurs.

"Paul" wrote:

Hi,

I am trying to run the following code but when i do it it falls over after
after about 200 lines with the following error message:-

Run Time Error 1004 Pastespecial Method of range class failed:-

Can someone please look at the code to find out why it's falling over on
this message?????? Thanks

Private Sub CommandButton1_Click()

'Works out how many setups we have on the PPM sample and calculate there value

Dim Message As String
Dim Myquestion As String

Application.ScreenUpdating = False


'Alerts the user how long it could take to run the calculations

Myquestion = "Are you sure you want to run calculation for " _
& Range("b1").Value - 11 & " accounts, this could take " _
& Round((Range("b1").Value - 11) / 2.4 / 60, 2) _
& " Minutes"

Message = MsgBox(Myquestion, vbQuestion + vbYesNo, "SetupCalculations")

If Message = vbNo Then

MsgBox "NO Calculations Done!!", vbOKOnly, "SetupCalculations"

Else

counter = 11
mynum = Range("b1")

Do While counter <= mynum

'The below few lines copy the fields needed to work out the asset setup value



Range("B10:ann10").Select

Selection.Copy
Range("B" & counter).Select

Range("B" & counter & ":ANN" & counter).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False


'The below few lines work out the asset value for setup assets

Application.CutCopyMode = True

Range("L60014:ANP60014").Select

Selection.Copy
Range("L" & counter + 60004).Select

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.PasteSpecial xlPasteAll

Application.CutCopyMode = False

'The below few line will paste special values into the calculated setups
assets after they have been calculated. Doing this will
'save on file size and make the calcualtions run quicker.

Application.CutCopyMode = True

Range("B" & counter & ":ANN" & counter).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

Application.CutCopyMode = True

Range("L" & counter + 60004 & ":ANP" & counter + 60004).Select

Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False

'The below line stop the code from copy mode and put the cursor back to cell
B9

mynum = mynum
counter = counter + 1

Loop

Range("b9").Select

Application.ScreenUpdating = True

Range("r3").Value = WorksheetFunction.Sum(Range("ANP60014:ANP1048576") ) /
WorksheetFunction.Sum(Range("C60014:C1048576"))

MsgBox "Your calculations are complete", vbOKOnly, "SetupCalculations"

End If

End Sub



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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run time error 1004 Object defined error [email protected] Excel Programming 1 May 15th 07 03:31 AM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 03:42 AM.

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"