View Single Post
  #5   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, 11:00 am, wrote:
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- Hide quoted text -

- Show quoted text -


Bill, Gary Thanks for your help.

Bill, I am using your code. But histogram gives an error saying that
"Input range must contain atleast one value".

So, I would like to have a condition like "If column in the
activehseet does not have any data, then skip that column and go to
next column". Please let me know.. Gary, if you know this, then please
let me know the code for this. Thanks