Friday, January 9, 2015

How can I apply this macro to all the pages in an excel file

I have a code to do a particular modification to some cells in a page. I'd like to apply this code at one click to all the pages in the excel file. I'm using VBA and am a newbie to it. Here's my code :


Sub H()
Dim B As Range, H As Range, I As Range
For Each B In Range("B7:B49").Cells
If IsNumeric(B) And B <> "" Then
Cells(B.Row, 9) = Trim(Cells(B.Row + 1, 8)) & Trim(Cells(B.Row + 2, 8))
Cells(B.Row + 1, 8) = ""
Cells(B.Row + 2, 8) = ""
If B.Row > 50 Then Exit For
End If
Next B
End Sub


I'd like to apply the above macro to all the pages in the excel sheet. How can I do that?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...