M
misscrf
Hi, I have seen some posts that are similar, but no one seems to have
the problem that I am having. I will post my macro in this, for anyone
that is interested.
My users get a csv file every month, and we have to clean it up. This
macro does that.
My last issues are this:
1) having the spreadsheet create page breaks whenever the value in
column B changes. Below is just that code.
Code:
--------------------
col = 2
LastRw = ActiveSheet.UsedRange.Rows.Count
For X = 2 To LastRw
If Cells(X, col) <> Cells(X - 1, col) And Cells(X, col) <> Range("B1") Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(X, col)
End If
Next
--------------------
The problem that I am having, is that my first page is just row 1. I
have row 1 repeat at the top of every page. It does make sense in the
code that this value changes, so it makes a page break. Can anyone help
me to adjust my code so that it will ignore the first row when it makes
the page breaks? The value of B1 will always be the same, so my thought
is to make that "If ...Then" statement include something that says not
if Cells(X, col) = B1. Make sense?
Second issue:
2) I want to take the value in column B, as it will be the same for any
given page due to the above page breaks, and put that in the footer.
I have commented out the code that I was having fun with trying. The
idea is that column B is a box number, and I want to have that box
number in the footer, so that it is easy to see on the sheet. Here is
my page setup code for headers and footers.
As I said, I commented out the right footer where I would put this
code. Any help would be great.
Code:
--------------------
With ActiveSheet.PageSetup
.CenterHeader = "Our Form"
.LeftFooter = Date
.CenterFooter = "Signature __________________________________"
' this is where I want the value --> .RightFooter = "Box Number: " & Column("B:B").Value
End With
--------------------
From the posts I have been reading, you cannot use formulas in the
footer. I wish this was not true. My idea was that many formulas or
functions could work here. Because I break the page on the value in
this column any function that finds the value of any B column cell in
the page could be used in this right footer. Like first or last would
work.
Anyway, if I cannot get this second part, I can still deploy the macro.
I just need to fix the first part.
For anyone who is interested, I will post my code in a reply. It is
too long as one whole post.
Thanks!
the problem that I am having. I will post my macro in this, for anyone
that is interested.
My users get a csv file every month, and we have to clean it up. This
macro does that.
My last issues are this:
1) having the spreadsheet create page breaks whenever the value in
column B changes. Below is just that code.
Code:
--------------------
col = 2
LastRw = ActiveSheet.UsedRange.Rows.Count
For X = 2 To LastRw
If Cells(X, col) <> Cells(X - 1, col) And Cells(X, col) <> Range("B1") Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(X, col)
End If
Next
--------------------
The problem that I am having, is that my first page is just row 1. I
have row 1 repeat at the top of every page. It does make sense in the
code that this value changes, so it makes a page break. Can anyone help
me to adjust my code so that it will ignore the first row when it makes
the page breaks? The value of B1 will always be the same, so my thought
is to make that "If ...Then" statement include something that says not
if Cells(X, col) = B1. Make sense?
Second issue:
2) I want to take the value in column B, as it will be the same for any
given page due to the above page breaks, and put that in the footer.
I have commented out the code that I was having fun with trying. The
idea is that column B is a box number, and I want to have that box
number in the footer, so that it is easy to see on the sheet. Here is
my page setup code for headers and footers.
As I said, I commented out the right footer where I would put this
code. Any help would be great.
Code:
--------------------
With ActiveSheet.PageSetup
.CenterHeader = "Our Form"
.LeftFooter = Date
.CenterFooter = "Signature __________________________________"
' this is where I want the value --> .RightFooter = "Box Number: " & Column("B:B").Value
End With
--------------------
From the posts I have been reading, you cannot use formulas in the
footer. I wish this was not true. My idea was that many formulas or
functions could work here. Because I break the page on the value in
this column any function that finds the value of any B column cell in
the page could be used in this right footer. Like first or last would
work.
Anyway, if I cannot get this second part, I can still deploy the macro.
I just need to fix the first part.
For anyone who is interested, I will post my code in a reply. It is
too long as one whole post.
Thanks!