View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
[email protected] ucanalways@gmail.com is offline
external usenet poster
 
Posts: 115
Default Macro to sequence ("$A:$A") to ("$IV:$IV")

On Oct 26, 9:52 am, wrote:
Is there any macro that can be made to simplify the code below,, such
that ("$A:$A"), is automatically replaced by B,C,D.....IV, insteading
of having something given below? Please let me know. Thanks

Application.Run "ATPVBAEN.XLA!Histogram", ActiveSheet.Range("$A:$A"),
_
"", Sheets("Sheet4").Range("$A:$A"), False, False, True, True

Application.Run "ATPVBAEN.XLA!Histogram", ActiveSheet.Range("$B:$B"),
_
"", Sheets("Sheet4").Range("$B:$B"), False, False, True, True

Application.Run "ATPVBAEN.XLA!Histogram", ActiveSheet.Range("$C:$C"),
_
"", Sheets("Sheet4").Range("$C:$C"), False, False, True, True

Application.Run "ATPVBAEN.XLA!Histogram", ActiveSheet.Range("$C:$C"),
_
"", Sheets("Sheet4").Range("$D:$D"), False, False, True, True
...........
...............
..................

Application.Run "ATPVBAEN.XLA!Histogram", ActiveSheet.Range("$IV:
$IV"), _
"", Sheets("Sheet4").Range("$IV:$IV"), False, False, True, True


I got the concept now but the code gives some error. Can someone help
rectifying the error?

Thanks

Sub hist_gen()
Dim rng As Range
Dim rng1 As Range

Dim i As Integer

For i = 1 To 256


Set rng = Range("A:IV")
'rng.Columns(i).Select

Set rng1 = rng.Columns(i)


Application.Run "ATPVBAEN.XLA!Histogram", ActiveSheet.rng1, _
"", Sheets("Sheet2").rng1, False, False, True, True

Next
End Sub