Offset rather than select/activate

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,066
Norie advised not to select or activate cells but I don't know how to offset from the activecell as in my following code.

The script looks for values in column D, if it finds the value it offsets the value from column A to another cell.

Code:
Sub Process1()
 
Application.Calculation = xlCalculationManual
Range("D2").Select
ActiveCell.Offset(0, -1).Select
Cells(65535, ActiveCell.Column).Select
   Range(Selection, Selection.End(xlUp)).Select
   ActiveCell.Select
   ActiveCell.Offset(0, 1).Select
Set BottomCell = ActiveCell
    Set TOPCELL = Cells(2, ActiveCell.Column)
      Range(TOPCELL, BottomCell).Select
 
 Dim Cell As Range
For Each Cell In Selection.Cells
If Cell.HasFormula = False Then
End If
 
 
If ActiveCell.Value = 2 Then
ActiveCell.Offset(-1, 1).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 3 Then
ActiveCell.Offset(-2, 2).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 4 Then
ActiveCell.Offset(-3, 3).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 5 Then
ActiveCell.Offset(-4, 4).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 6 Then
ActiveCell.Offset(-5, 5).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 7 Then
ActiveCell.Offset(-6, 6).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 8 Then
ActiveCell.Offset(-7, 7).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 9 Then
ActiveCell.Offset(-8, 8).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 10 Then
ActiveCell.Offset(-9, 9).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 11 Then
ActiveCell.Offset(-10, 10).Value = ActiveCell.Offset(0, -3).Value
End If
 
ActiveCell.Offset(1, 0).Select
Next
Application.Calculation = xlCalculationAutomatic
 
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top