Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Data samples

Hey
I have a large set of data samples and i need to put in a function which can
tell me the errors between two numbers. I have tried with this one:
Sub ErrorTrueFalse()
'
' Macro2 Macro
'

'
ActiveCell.Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveCell.Offset(1, -33).Range("A1").Select


End Sub

but i get an error saying 'Application-defined or object-defined error' with
debug on the last line.

Can someone please help me fix this and make the macro go as a loop for 550
rows.

In advance thanks!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Data samples

Try the below macro...

Sub ErrorTrueFalse()
Dim lngCol As Long
For lngCol = ActiveCell.Column To 100 Step 3
Cells(ActiveCell.Row, lngCol).FormulaR1C1 = _
"=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
Next
End Sub

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


"Anders J." wrote:

Hey
I have a large set of data samples and i need to put in a function which can
tell me the errors between two numbers. I have tried with this one:
Sub ErrorTrueFalse()
'
' Macro2 Macro
'

'
ActiveCell.Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveCell.Offset(1, -33).Range("A1").Select


End Sub

but i get an error saying 'Application-defined or object-defined error' with
debug on the last line.

Can someone please help me fix this and make the macro go as a loop for 550
rows.

In advance thanks!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default Data samples

What is the purpose of using Offset followed by Range("A1")? Offset returns a
range object, therefore you should be able to do:
ActiveCell.Offset(0,3).select
as applicable, or
ActiveCell.Offset(1,-33).select

I haven't seen the ScrollColumn feature, but it if it changes your active
cell, then -33 would take you to a negative cell and would throw an error.

If you take a look in your watch window, at:
activecell.column you should be able to tell if it will go negative. Also
put a stop in at the line, run your code, and "Watch" the value of column to
see what it is before and after attempting to run that line.

As for looping, if you specifically need a 550 line loop, it looks like you
can use a for loop from 1 to 550

Add (just before the first Activecell.select):

Dim I as long

Then (after the dim statement above):

For I = 1 to 550
.... all the activecell offset etc work.

Next I before the End Sub
"Anders J." wrote:

Hey
I have a large set of data samples and i need to put in a function which can
tell me the errors between two numbers. I have tried with this one:
Sub ErrorTrueFalse()
'
' Macro2 Macro
'

'
ActiveCell.Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveCell.Offset(1, -33).Range("A1").Select


End Sub

but i get an error saying 'Application-defined or object-defined error' with
debug on the last line.

Can someone please help me fix this and make the macro go as a loop for 550
rows.

In advance thanks!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Data samples

Hi,

Maybe you could condense your code to this

For x = 0 To 34 Step 3
Cells(ActiveCell.Row, ActiveCell.Column + x).FormulaR1C1 = _
"=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
Next
Range("A1").Select

Mike

"Anders J." wrote:

Hey
I have a large set of data samples and i need to put in a function which can
tell me the errors between two numbers. I have tried with this one:
Sub ErrorTrueFalse()
'
' Macro2 Macro
'

'
ActiveCell.Select
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<(RC[-2]*0.75),FALSE,TRUE)"
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveCell.Offset(1, -33).Range("A1").Select


End Sub

but i get an error saying 'Application-defined or object-defined error' with
debug on the last line.

Can someone please help me fix this and make the macro go as a loop for 550
rows.

In advance thanks!!

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
Random Samples random Excel Discussion (Misc queries) 1 January 13th 10 04:54 PM
User form Samples (to query data) Matts Excel Discussion (Misc queries) 0 October 10th 07 05:15 PM
samples kyoshirou Excel Discussion (Misc queries) 8 June 24th 07 11:15 AM
samples of pay studs check studs New Users to Excel 2 March 9th 06 01:40 AM
Any Samples??? Krefty Excel Worksheet Functions 0 June 10th 05 01:55 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"