dividing cells range

Public Schedule Face-to-Face & Virtual Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Dividing Cells in a Range

Dividing Cells in a Range

resolvedResolved · Medium Priority · Version 2007

Chris has attended:
Excel VBA Intro Intermediate course

Dividing Cells in a Range

NB/ Question submitted by agreement with and allocated to Stephen

How do I divide by 100 the Cells in a Range that I have moved across? Here is my code for this particular section:

Sub CopyData()

Dim intRowCount As Integer
Dim intColumnCount As Integer
Dim intTargetRowCount As Integer

Dim strSourceRangeStart As String
Dim strSourceRangeFinish As String

Dim strTargetRangeStart As String
Dim strTargetRangeFinish As String

Dim strSourceRange As String
Dim strTargetRange As String

intTargetRowCount = 2

For intRowCount = 1 To 64
If Sheets("RfC").Range("A5").Cells(intRowCount - 3, 1).Value = "" _
And Not Sheets("RfC").Range("A5").Cells(intRowCount, 2).Value = "" Then
strSourceRangeStart = Sheets("RfC").Range("A5").Cells(intRowCount, 1).Address
strSourceRangeFinish = Sheets("RfC").Range("A5").Cells(intRowCount, 25).Address

strTargetRangeStart = Sheets("Table").Cells(intTargetRowCount, 2).Address
strTargetRangeFinish = Sheets("Table").Cells(intTargetRowCount, 26).Address

strSourceRange = strSourceRangeStart & ":" & strSourceRangeFinish
strTargetRange = strTargetRangeStart & ":" & strTargetRangeFinish

Sheets("Table").Range(strTargetRange).Value = _
Sheets("RfC").Range(strSourceRange).Value

Sheets("Table").Range(strTargetRange).Value = (Sheets("Table").Range(strTargetRange).Value) / 100

intTargetRowCount = intTargetRowCount + 1
End If
Next intRowCount

End Sub

RE: Dividing Cells in a Range

I did it myself! I used a function module to do the calculation. :D

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Copying Formulae Quickly

There is a quicker way of copying a formula down a column.

Just point and double click on the black autofill handle in the right hand corner of a cell.

This will work providing you have some data in the column to the left of the column.

Sandy

View all Excel hints and tips


Server loaded in 0.06 secs.