Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default updating a workbook

Hi i am trying to use some visual basic code to update
everybodys results depending on there score e.g. if the
new value is greater than there current value then it will
put "Fail" in there record.

here is the code i have tried so far!

With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End
(xlDown))
End With

For Each cell In rng
If cell.Offset(0, 26).Value Sheets
("sheet1").Range("AU1").Value Then
cell.Offset(0, 27) = "Fail"
Else
cell.Offset(0, 27) = "Pass"
End If
If cell.Offset(0, 36).Value Sheets
("sheet1").Range("AV1").Value Then
cell.Offset(0, 37) = "Fail"
Else
cell.Offset(0, 37) = "Pass"
End If
If cell.Offset(0, 44).Value Sheets
("sheet1").Range("AW1").Value Then
cell.Offset(0, 45) = "Fail"
Else
cell.Offset(0, 45) = "Pass"
End If
Next

Thank you,

Robert Couchman
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default updating a workbook

The code would appears like it would work. It compiles with no complaints.
What is the issue. do you want to check against a value in the same row in
columns AU, AV, AW?

Sub Tester1()
Dim rng as Range, cell as Range, i as long
With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), _
.Cells(2, 1).End(xlDown))
End With
i = 0
For Each cell In rng
If cell.Offset(0, 26).Value _
Sheets("sheet1").Range("AU2").Offset(i,0).Value Then
cell.Offset(0, 27) = "Fail"
Else
cell.Offset(0, 27) = "Pass"
End If
If cell.Offset(0, 36).Value _
Sheets("sheet1").Range("AV2").Offset(i,0).Value Then
cell.Offset(0, 37) = "Fail"
Else
cell.Offset(0, 37) = "Pass"
End If
If cell.Offset(0, 44).Value _
Sheets("sheet1").Range("AW2").Offset(i,0).Value Then
cell.Offset(0, 45) = "Fail"
Else
cell.Offset(0, 45) = "Pass"
End If
i = i + 1
Next
End Sub


--
Regards,
Tom Ogilvy


"Robert Couchman" wrote in message
...
Hi i am trying to use some visual basic code to update
everybodys results depending on there score e.g. if the
new value is greater than there current value then it will
put "Fail" in there record.

here is the code i have tried so far!

With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End
(xlDown))
End With

For Each cell In rng
If cell.Offset(0, 26).Value Sheets
("sheet1").Range("AU1").Value Then
cell.Offset(0, 27) = "Fail"
Else
cell.Offset(0, 27) = "Pass"
End If
If cell.Offset(0, 36).Value Sheets
("sheet1").Range("AV1").Value Then
cell.Offset(0, 37) = "Fail"
Else
cell.Offset(0, 37) = "Pass"
End If
If cell.Offset(0, 44).Value Sheets
("sheet1").Range("AW1").Value Then
cell.Offset(0, 45) = "Fail"
Else
cell.Offset(0, 45) = "Pass"
End If
Next

Thank you,

Robert Couchman



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default updating a workbook

Robert,
It would help if you explained wht you expected to happen and what was
happening, rather than leave it to us to figure out. I was just about to
respond that I didn';t know what you wanted, wehen I spotted that the test
cell wasn't moving.

Is this what you want?

With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
rng.Select

For Each cell In rng
If cell.Offset(0, 26).Value .Cells(cell.Row, "AU").Value Then
cell.Offset(0, 27) = "Fail"
Else
cell.Offset(0, 27) = "Pass"
End If
If cell.Offset(0, 36).Value .Cells(cell.Row, "AV").Value Then
cell.Offset(0, 37) = "Fail"
Else
cell.Offset(0, 37) = "Pass"
End If
If cell.Offset(0, 44).Value .Cells(cell.Row, "AW").Value Then
cell.Offset(0, 45) = "Fail"
Else
cell.Offset(0, 45) = "Pass"
End If
Next
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Robert Couchman" wrote in message
...
Hi i am trying to use some visual basic code to update
everybodys results depending on there score e.g. if the
new value is greater than there current value then it will
put "Fail" in there record.

here is the code i have tried so far!

With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End
(xlDown))
End With

For Each cell In rng
If cell.Offset(0, 26).Value Sheets
("sheet1").Range("AU1").Value Then
cell.Offset(0, 27) = "Fail"
Else
cell.Offset(0, 27) = "Pass"
End If
If cell.Offset(0, 36).Value Sheets
("sheet1").Range("AV1").Value Then
cell.Offset(0, 37) = "Fail"
Else
cell.Offset(0, 37) = "Pass"
End If
If cell.Offset(0, 44).Value Sheets
("sheet1").Range("AW1").Value Then
cell.Offset(0, 45) = "Fail"
Else
cell.Offset(0, 45) = "Pass"
End If
Next

Thank you,

Robert Couchman



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default updating a workbook

Can also be written more succinctly as

With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
rng.Select

For Each cell In rng
cell.Offset(0, 27) = IIf(cell.Offset(0, 26).Value
..Cells(cell.Row, "AU").Value, _
"Fail", "Pass")
cell.Offset(0, 37) = IIf(cell.Offset(0, 36).Value
..Cells(cell.Row, "AV").Value, _
"Fail", "Pass")
cell.Offset(0, 45) = IIf(cell.Offset(0, 44).Value
..Cells(cell.Row, "AW").Value, _
"Fail", "Pass")
Next
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
Robert,
It would help if you explained wht you expected to happen and what was
happening, rather than leave it to us to figure out. I was just about to
respond that I didn';t know what you wanted, wehen I spotted that the test
cell wasn't moving.

Is this what you want?

With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
rng.Select

For Each cell In rng
If cell.Offset(0, 26).Value .Cells(cell.Row, "AU").Value

Then
cell.Offset(0, 27) = "Fail"
Else
cell.Offset(0, 27) = "Pass"
End If
If cell.Offset(0, 36).Value .Cells(cell.Row, "AV").Value

Then
cell.Offset(0, 37) = "Fail"
Else
cell.Offset(0, 37) = "Pass"
End If
If cell.Offset(0, 44).Value .Cells(cell.Row, "AW").Value

Then
cell.Offset(0, 45) = "Fail"
Else
cell.Offset(0, 45) = "Pass"
End If
Next
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Robert Couchman" wrote in message
...
Hi i am trying to use some visual basic code to update
everybodys results depending on there score e.g. if the
new value is greater than there current value then it will
put "Fail" in there record.

here is the code i have tried so far!

With Worksheets("sheet1")
Set rng = .Range(.Cells(2, 1), .Cells(2, 1).End
(xlDown))
End With

For Each cell In rng
If cell.Offset(0, 26).Value Sheets
("sheet1").Range("AU1").Value Then
cell.Offset(0, 27) = "Fail"
Else
cell.Offset(0, 27) = "Pass"
End If
If cell.Offset(0, 36).Value Sheets
("sheet1").Range("AV1").Value Then
cell.Offset(0, 37) = "Fail"
Else
cell.Offset(0, 37) = "Pass"
End If
If cell.Offset(0, 44).Value Sheets
("sheet1").Range("AW1").Value Then
cell.Offset(0, 45) = "Fail"
Else
cell.Offset(0, 45) = "Pass"
End If
Next

Thank you,

Robert Couchman





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
Updating formulas on workbook Byron720 Excel Discussion (Misc queries) 1 October 16th 08 01:10 PM
Automatically updating a workbook from a different workbook day by not an excel guru Excel Discussion (Misc queries) 4 September 20th 06 03:35 AM
My workbook links are not updating (its 30,000 KB size workbook). rselena Excel Discussion (Misc queries) 1 August 14th 06 09:14 PM
Auto updating a workbook with data from another workbook Richard Excel Discussion (Misc queries) 0 November 6th 05 03:50 PM
Transparently updating another workbook from the current workbook lothario[_40_] Excel Programming 3 November 2nd 03 01:58 AM


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