ThomJenkins
New Member
- Joined
- Oct 1, 2011
- Messages
- 13
Hi all, appreciate any help you can offer
On a regular basis I receive a file with multiple worksheets, each with a group of cells that I want to perform a simple conversion. Although I haven't used a For Each loop before, I get the idea and thought this would be the best way to go.
The code does everything I want... and more - it converts the final sheet twice! As I'm new to the loops I'm expecting something obvious that I've missed.
Thanks in advance for your help and time.
TJ
Code:
Dim wksht As Worksheet
Dim cell As Range
Dim XRate As Currency
XRate = 1.6
Application.ScreenUpdating = False
For Each wksht In Worksheets
wksht.Activate
'Selection of cells goes here....
Range("D5:E15").Select
For Each cell In Selection
cell.Value = cell.Value / XRate
Next cell
Range("A1").Select
Next wksht
On a regular basis I receive a file with multiple worksheets, each with a group of cells that I want to perform a simple conversion. Although I haven't used a For Each loop before, I get the idea and thought this would be the best way to go.
The code does everything I want... and more - it converts the final sheet twice! As I'm new to the loops I'm expecting something obvious that I've missed.
Thanks in advance for your help and time.
TJ
Code:
Dim wksht As Worksheet
Dim cell As Range
Dim XRate As Currency
XRate = 1.6
Application.ScreenUpdating = False
For Each wksht In Worksheets
wksht.Activate
'Selection of cells goes here....
Range("D5:E15").Select
For Each cell In Selection
cell.Value = cell.Value / XRate
Next cell
Range("A1").Select
Next wksht