Hello All,
Thank you for your help on past posts, your information was very helpful so I thought I would try again with a new challenge.
I am trying to resize a picture on a worksheet to fit a dynamic measurement(the size of the page is different depending on the contents in cells).
I am doing this all in VBA.
so what I have come up with is that I need to
1) determine the total column width of only the non-hidden(visible) cells.
2) resize my picture to those measurements, so I can get an exact fit, and it doesn't create a new page break, by going over.
I have found some code on forums, and am thinking of something like this as a solution(although I don't know how to complete it):
For summing column widths:
Code:
Function Sum_Visible_Columns(Columns_To_Sum As Object)
Application.Volatile
For Each Column In Columns_To_Sum
If Columns.Hidden = False Then
total = total + cell.Width
End If
End Function-or-
Code:
Dim rng1 As Range
Set rng1 = rng.SpecialCells(xlVisible)
then I would have to use that total column width number as either inches or pixels to resize the width and height to fit on one page of the activesheet.
for that I was thinking of something like this:
Code:
Dim shp As Shape
shp.LockAspectRatio = msoFalse
shp.Height = x(total column width times something????)
shp.Width = y(the total column width)
I appreciate everyones help, thank you,
-alex
Thank you for your help on past posts, your information was very helpful so I thought I would try again with a new challenge.
I am trying to resize a picture on a worksheet to fit a dynamic measurement(the size of the page is different depending on the contents in cells).
I am doing this all in VBA.
so what I have come up with is that I need to
1) determine the total column width of only the non-hidden(visible) cells.
2) resize my picture to those measurements, so I can get an exact fit, and it doesn't create a new page break, by going over.
I have found some code on forums, and am thinking of something like this as a solution(although I don't know how to complete it):
For summing column widths:
Code:
Function Sum_Visible_Columns(Columns_To_Sum As Object)
Application.Volatile
For Each Column In Columns_To_Sum
If Columns.Hidden = False Then
total = total + cell.Width
End If
End Function-or-
Code:
Dim rng1 As Range
Set rng1 = rng.SpecialCells(xlVisible)
then I would have to use that total column width number as either inches or pixels to resize the width and height to fit on one page of the activesheet.
for that I was thinking of something like this:
Code:
Dim shp As Shape
shp.LockAspectRatio = msoFalse
shp.Height = x(total column width times something????)
shp.Width = y(the total column width)
I appreciate everyones help, thank you,
-alex