-6

I have a number of log files that I am importing into Excel and I am trying to create a macro that can find numbers greater than 20 in a specific column then divide the cells that match the criteria by 1000 (converting from Kb to Mb). Any help would be greatly appreciated.

Thanks,

Simon

pnuts
  • 58,317
  • 11
  • 87
  • 139
user3188967
  • 1
  • 1
  • 2

2 Answers2

1

Let's say your Kb values start in row 1 of column A, write this formula in column B :

=IF(A1>20, A1/1000, A1)

Basically, what this does, is tell the computer that if A1 is greater than 20, put A1/1000 in this cell, otherwise put A1. Stretching this formula down the column will give you the right formula for each row.

Bernard Saucier
  • 2,240
  • 1
  • 19
  • 28
1

Macro Version .. if u have data in A column

Sub test()
Dim erange As Range
Dim lrow As long

With ActiveSheet
lrow = .Range("A" & .Rows.Count).End(xlUp).Row

For Each erange In .Range("A2:A" & lrow)

If erange.Value > 20 Then

erange.Offset(0, 1).Value = erange.Value / 1000

End If

Next erange

End With

End Sub
Sathish Kothandam
  • 1,530
  • 3
  • 16
  • 34