Close Window   
Free Ebook
Got an Excel Question?
Ask it in our Excel forum!
TeachExcel.com
Subscribe for Free Excel tips & more!
E-mail:
Advertisements



Column And Row Lenght And Width Pixel Values

Forum Register
Search Excel Forum Posts, Tutorials, Macros, Tips, and More

i need my excel to show a pop up bar which shows the pixel values of the columns and rows width and height sizes im using excel 2007

View Answers     

Similar Excel Tutorials

How to Resize Rows and Columns in Excel Quickly
Resizing rows and columns in Excel is an easy process. Simply left click in between the columns and drag the mouse ...
AutoFilter with an Excel Macro
This Excel tip shows you how you can use an Excel Macro in order to run a Filter on data within a spreadsheet. Filt ...
OFFSET Function in Excel
The OFFSET function in Excel returns a cell or range reference that is a specified number of rows and columns away ...
Sort Data Alphabetically or Numerically in Excel 2007 and Later
This Excel tip shows you how to Sort Data Alphabetically and Numerically in Excel 2007. This is a great feature to ...

Helpful Excel Macros

Delete Empty Columns
- This macro will delete columns which are completely empty. This means that if there is no data within the entire column
Filter Data Sets on Multiple Columns with Multiple Criteria at Once in Excel - AutoFilter
- This Excel macro allows you to filter a data set on multiple columns and criteria at once. This means that you can filt
Reverse Row or Column Order in a Worksheet
- This macro reverses the order of a selected row or column in excel. It will completely reverse the data.
Filter Data in Excel to Display Records that Contain a Value Between Two Values - AutoFilter.
- This free Excel macro filters data to display only those records or rows that contain a value between two values. For e
Replace Formulas with Values (For The Entire Workbook)
- This macro will convert every formula in an entire workbook into its respective value. This is basically a quick way to

Similar Topics







Hi

I have never set column width before, If posibel could someone show me how to do it.

I have a sheet which i would like to set
Rows 5 and downward to height=30:00(40 pixels).
Column at diffrent width.
Column A = 4.43 (36 pixel)
Column B = 6.00 (47 pixel)
Column C = 16.71 (122 pixel)
Column D = 24.57 (177 pixel)
Column E = 15.86 (116 pixel)
Column F = 18.86 (137 pixel)

Not sure how to do this, have looked at lots of answers but more confused now.

If someone can assist.

Regards


Greetings,
This "smells" like a simple question, but I've had no luck finding a way to [programmatically] adjust the App.Window to fit around some cells.

I've found "Application.Goto", also the Application.Width/Height setting. The App.Width setting is pixel based, so if there's an easy way to know a cell's pixel-location, that'll work too!

Thanks/Cheers!




Hello, I am doing a project for an individual in which I load in an image to a excel sheet. Then on sheet 2 it shows the color of pixel in each cell according to the pixel location in the image. And on sheet 3 it shows the RGB value of each pixel in their according location in the sheet based on pixel location. I had this working all fine and dandy in Excel 2010, but they apparently need it in Excel 2013. I'm having some issues with the GetPixel API method in Excel 2013. When used in 2010 it retrieves the color of the pixel at the location I need just perfectly, but when used in Excel 2013 all it ever returns is -1. I'm coming here as a last resort to see if anyone has any idea of a work around for this or if this is a known issue at all. I've tried grabbing several different hwnd's, but have had no luck. Thanks so much.

Edit - Apparently I was just grabbing the wrong handle. All is well. Thanks anyways.

Note I was using Visual studio 2010 and Excel 2010 for this!

But I decided to try and colour a sheet from a JPG dont ask me why, but it seemed like a fun application, the first thing I found is that there is a large lack of information but here is the code incase you wish to try!

Code:

Imports System.Drawing
Imports Microsoft.Office.Interop.Excel

Public Class ThisWorkbook

    Private Sub ThisWorkbook_Startup() Handles Me.Startup

        Dim StepSize As Integer = 4 'speed up by only processing every nth pixel

        Dim MyImage As New Bitmap("C:\Users\Daz\Pictures\Elephants\DSCF0789.jpg")

        Dim PixelColor As Color  ' Contains the pixel from the image
        Dim GreyScale As Integer  ' used in converting to greyscale, since it overloads the maximum formatting otherwise


        Me.Application.ScreenUpdating = False
        Me.Application.EnableEvents = False

        For x = 0 To MyImage.Width - 1 Step StepSize
            Me.Sheets(1).Range("A1").offset(1, x / StepSize).columnwidth = 0.2 ' seemed to be 2 pixel wide excel cells
        Next

        For y = 0 To MyImage.Height - 1 Step StepSize
            Me.Sheets(1).Range("A1").offset(y / StepSize, 1).rowheight = 1.8 ' seemed to be 2 pixel wide excel cells

        Next

        For x = 0 To MyImage.Width - 1 Step StepSize
            For y = 0 To MyImage.Height - 1 Step StepSize

                'read pixel from bitmap
                PixelColor = MyImage.GetPixel(x, y)

                ' convert pixel into greyscale
                GreyScale = PixelColor.R * 0.3 + PixelColor.G * 0.59 + PixelColor.B * 0.11
                ' set cell on excel sheet to pixel color
                Me.Sheets(1).Range("A1").offset(y / StepSize, x / StepSize).interior.color = RGB(GreyScale, GreyScale, GreyScale)
            Next
        Next

        ' select image range
        Me.Sheets(1).range("A1:" & Me.Sheets(1).Range("A1").offset(MyImage.Height / StepSize - 1, MyImage.Width / StepSize - 1).address()).select()
        'zoom to full image
        Me.Windows(1).Zoom = True

        Me.Application.EnableEvents = True
        Me.Application.ScreenUpdating = True

        MyImage = Nothing


    End Sub

    Private Sub ThisWorkbook_Shutdown() Handles Me.Shutdown

    End Sub

End Class



The resulting file is here (its too big to post here) :-

http://cid-7c0eef3f7aa6f25b.skydrive...0Pricture.xlsx

ignore the error, as I havent included the compiled code!


For some reason, I cannot get my worksheet to display a cell's pixel value when I make a colum or row wider. Thoughts?


In the same workbook I have two sheets that have the same column width of 50, but the pixel count is 355 on one sheet and 710 on the other. This of course causes viewing and printing issues. How does this get corrected?


Hi

Can someone please guide me how i can set the below macro to do loop until it gets to row 450

Column A,B,E & F = 160 Pixel and Column C & D = 28 pixel
Row 1 = 27pixel
Row 2 = 92 pixel
Row 3 = 26 pixel
Row 4 = 3 Pixel


Code:

Sub Set_label_page()
'
' Setup page for label.
'

    Columns("A:A").ColumnWidth = 22.14
    Columns("B:B").ColumnWidth = 22.14
    Columns("E:E").ColumnWidth = 22.14
    Columns("F:F").ColumnWidth = 22.14
    Columns("C:C").ColumnWidth = 3.29
    Columns("D:D").ColumnWidth = 3.29
    Rows("1:1").RowHeight = 20.25
    Rows("2:2").RowHeight = 69
    Rows("3:3").RowHeight = 20.25
    Rows("4:4").RowHeight = 2.25
    Range("A2:B2").Select
        Selection.Merge
    Range("E2:F2").Select
        Selection.Merge
        
End Sub


I want repeat the measurement of row 1 to 4 over and over until it get to row 450.

Once the rows are set merge cells A2:B2 and then E2:F2 move down 4 rows merge A6:B6 and then E6:F6 and repeat untl row 450.

Can someone show me how to repeat loop

Please see the attached file. I ave created button which user presses to setup sheet.

Help would be apricated.


Hello All,

I have been scouring the boards for a solution to my problem and I have found a similar problem and solution but it is does not work with my specific case/workbook.

I have a program created in XNA .net framework which will take an image and break it down into individual pixel RGB values and create a .csv file with the RGB in each cell for each pixel. I would like to cange the font colour and background of the cell to match the value in the cell. The values in each cell are written 0,0,0 > 255,255,255. The problem is similar to this post http://excel.bigresource.com/Track/excel-Y30kLP4F/ but i need to affect the cell containing the value, and the values are written in each cell instead or separated across 3 columns.

I want to recreate the image as a coloured data set with each cell representative of a pixel or an image, containing the RGB value and background colour or the code conatined in the cell...

Any ideas


I have a single column which I list all the door sizes offered. Doors are listed by width and then height.

Example of Door Sizes Offered Column (info for clarity)
3068 (3'-0" x 6'-8")
3070 (3'-0" x 7'-0")
4040 (4'-0" x 4'-0")
4068 (4'-0" x 6'-8")
4070 (4'-0" x 7'-0")
5068 (5'-0" x 6'-8")
5070 (5'-0" x 7'-0")
*Actual List is about 300 sizes

User Inputs - Each their own cell
Width in Feet
Width in Inches
Height in Feet
Height in Inches

If Door Size input by user does not exist I want to select the next size door with equal or greater width and height. I was going to use next larger number but this does not always out door with larger height since second variable. Example client wants a 3868 the next largest number is a 4040 so found a good width but the height is a problem.

I was hoping to find a formula solution and stay away from a custom vba function. Any help would be great.

I can break out the width and height into their own column and place side by side if this helps.


Hi,

I have charts that needs to be placed on specific position and have specific sizes on a chartsheet. I use chartobjects(i).plotarea (top, left, width, height) for that. Unfortunately when I set these values they still change, there is some scaling going on in Excel and they won't get the specified size. I have been looking on the internet and finally I found a piece of code which works, but still not good enough, because the legend is also not good positioned

De data for resizing the charts (ChtNew), the legends and the charttitle I get from other charts (ChtOrig). The legend.legendposition of ChtOrig does not have a value but it still have a top,left,height en width which I use.

I show you my code, the part with the for-next is taken from the internet.

Code:

with ChtNew.legend
           .Top = ChtOrig.Legend.Top
           .Height = ChtOrig.Legend.Height
           .Left = ChtOrig.Legend.Left
           .Width = ChtOrig.Legend.Width   '* 1.1
           .Top = ChtOrig.Legend.Top + ChtOrig.ChartTitle.Top
end with

With ChtNew.Plotarea
        .Top = ChtOrig.PlotArea.Top
        .Height = ChtOrig.PlotArea.Height
        .Width = ChtOrig.PlotArea.Width
        .Left = ChtOrig.PlotArea.Left
        
         For i = 1 To ChtOrig.PlotArea.Top
           .Top = i
           If .Top = ChtOrig.PlotArea.Top Then
              Exit For
           End If
        Next i
        
        For i = 1 To ChtOrig.PlotArea.Height
           .Height = i
           If .Height = ChtOrig.PlotArea.Height Then
              Exit For
           End If
        Next i

        For i = 1 To ChtOrig.PlotArea.Left
           .Left = i
           If .Left = ChtOrig.PlotArea.Left Then
              Exit For
           End If
        Next i
        
        For i = 1 To ChtOrig.PlotArea.Width
           .Width = i
           If .Width = ChtOrig.PlotArea.Width Then
              Exit For
           End If
        Next i
        
end with





Hello Everyone,

I am importing some text files into an excel worksheet. I want to change the format just a little bit. For each date I have 5 rows (pixel: 25, 37, 50, 100, and 200). When I import my data the date is in the same row as my pixel numbers. I want to place the date in another column to the left of these pixel numbers.

Below is an example of my "spreadsheet" The first 5 lines (with date "2008_308.txt" next to each pixel number is what I want it to look like and the next (with date "2008_309.txt" is how it is imported with only one date above the pixel numbers. I could do this manually, but I have many years of data to import. And would like a way to kind of copy/paste these multiple items at the same time. Any ideas?

Thanks,
Melissa


____________ Pixel Area(%) Cumm. Area Count Area (km^2)
2008_308.txt 25
2008_308.txt 37
2008_308.txt 50
2008_308.txt 100
2008_308.txt 200
____________ 2008_309.txt
____________ 25
____________ 37
____________ 50
____________ 100
____________ 200




I created a program that works in Excel 2007 and 2010, but there is one sub that I cannot get to work in 2013 which does the following:

When there is a picture on the sheet (top left at cell AA1)
Set the cursor position onto a specific pixel location
Get cursor position
Get pixel color at that position
Set the fill color of the cell behind that position to the pixel color
Loop

I am wondering if there are any functions that I used that work differently in Excel 2013 compared to 2010 and 2007 because when I run the sub, every cell is turned to white (when obviously the image I am using is not just white). It would be a huge help if someone could identify what is causing the problem! Here is the code for that sub:



Please Login or Register  to view this content.



Hello,


I'm having the following question about the row height and collumn width in Excel 2003.

Are these values in inches, milimeters or something else ?

I have a cel with a row height of 12,75 and a collumn width of 18,14.
When i look at the dimensions of the cel the width should be at least 3 times the height.

Are different units used for the height and width of a row or collumn ?
Which units are used and can they be changed somewhere ?
Maybe in the settings in Excel (2003 version) ?

Who can help me solve this little problem ?

Thanks.


Flash.


Hi,

I have made charts in VBA charts that needs to be placed on specific position and have specific sizes on a chartsheet. I use plotarea (top, left, width, height) for that. Unfortunately when I set these values they keep chaning, there is some scaling going on in Excel and they won't get the specified size. I have been looking on the internet and finally I found a piece of code which works, but still not good enough, because the legend is also not good positioned

De data for resizing the new charts (ChtNew), the legends and the charttitle I get from other charts (ChtOrig). The legend.legendposition of ChtOrig does not have a value but it still have a top,left,height en width which I use.

I show you my code, the part with the for-next is taken from the internet.
I am trying to find a solution now for 3 days and now I only dream of huge charts (which is not good). So please can someone help me with this? This is the last forum, that I can try, I didn't get reactions from others.

Code:

with ChtNew.legend
           .Top = ChtOrig.Legend.Top
           .Height = ChtOrig.Legend.Height
           .Left = ChtOrig.Legend.Left
           .Width = ChtOrig.Legend.Width   '* 1.1
           .Top = ChtOrig.Legend.Top + ChtOrig.ChartTitle.Top
end with

With ChtNew.Plotarea
        .Top = ChtOrig.PlotArea.Top
        .Height = ChtOrig.PlotArea.Height
        .Width = ChtOrig.PlotArea.Width
        .Left = ChtOrig.PlotArea.Left
        
         For i = 1 To ChtOrig.PlotArea.Top
           .Top = i
           If .Top = ChtOrig.PlotArea.Top Then
              Exit For
           End If
        Next i
        
        For i = 1 To ChtOrig.PlotArea.Height
           .Height = i
           If .Height = ChtOrig.PlotArea.Height Then
              Exit For
           End If
        Next i

        For i = 1 To ChtOrig.PlotArea.Left
           .Left = i
           If .Left = ChtOrig.PlotArea.Left Then
              Exit For
           End If
        Next i
        
        For i = 1 To ChtOrig.PlotArea.Width
           .Width = i
           If .Width = ChtOrig.PlotArea.Width Then
              Exit For
           End If
        Next i
        
end with





Hello all,

I'm trying to export charts directly from excel as gif or png. I've found a previous post (here) that gives a couple code snippets to do so, but I'm having trouble putting them together. This is what I've got in a module in my personal.xls:

Code:

'Code courtesy Stephen Bullen
'API's for getting the factors to convert points to pixels
Private Declare Function GetDC Lib "user32" ( _
                ByVal hwnd As Long) As Long

Private Declare Function GetDeviceCaps Lib "Gdi32" ( _
                ByVal hDC As Long, _
                ByVal nIndex As Long) As Long

Private Declare Function ReleaseDC Lib "user32" ( _
                ByVal hwnd As Long, _
                ByVal hDC As Long) As Long

Private Const LOGPIXELSX = 88
Private Const LOGPIXELSY = 90

'The width of a pixel in Excel's userform coordinates
Public Function PointsPerPixelX() As Double
    Dim hDC As Long

    hDC = GetDC(0)

    'A point is defined as 1/72 of an inch and LOGPIXELSX returns
    'the number of pixels per logical inch, so divide them to give
    'the width of a pixel in Excel's userform coordinates
    PointsPerPixelX = 72 / GetDeviceCaps(hDC, LOGPIXELSX)

    ReleaseDC 0, hDC

End Function

'The width of a pixel in Excel's userform coordinates
Public Function PointsPerPixelY() As Double
    Dim hDC As Long

    hDC = GetDC(0)

    'A point is defined as 1/72 of an inch and LOGPIXELSX returns
    'the number of pixels per logical inch, so divide them to give
    'the width of a pixel in Excel's userform coordinates
    PointsPerPixelY = 72 / GetDeviceCaps(hDC, LOGPIXELSY)

    ReleaseDC 0, hDC

End Function


Sub ExportChart2()

Dim DesiredPixels As Double

    DesiredPixels = 1000

    With ActiveChart.Parent
        .width = DesiredPixels * PointsPerPixelX
        .Height = DesiredPixels * PointsPerPixelY
    End With

    ActiveChart.Export ActiveWorkbook.Path & "\chartexport.gif", "GIF"

End Sub


However, it crashed on the lines in my macro, at .width = Desired... under With ActiveChart.Parent, saying the "object doesn't support the property or method." I don't really know what the functions from Stephen Bullen do, but obviously it's not liking something I'm doing. Any ideas?

Thanks!


I have several black rectangular shape objects with rounded corners on my 2007 sheet. I have each one sized as wide as the black colored cells they overlap (or so I think). I've zoomed in 400% to make sure they were lined up properly and they look great at 400%.

When I zoom out to 100%, every one of the rectangles are aligned left to each cell correctly, but they are all 1 pixel shorter and look to be 1 pixel short on the right side of the cell.

But then when I print the sheet, the rectangular shapes in the printout appear to be 1 pixel wider and hang off the right side of the cell by 1 pixel. The left side is still aligned correctly.

Does anyone know what is going on and how I could fix this?

I could just make them 1 pixel longer so it looks right when viewing at 100%, but then my printout will look like it is 2 pixels wider and hang off the right side of the cells by 2 pixels.


Anyone know of a way to get the pixel coordinate (say TOP) for a particular row. Currently, i use ActiveSheet.ChartObjects("chart 11").Top = 305 to move my chart to coordinate 305. However, when another user has a different screen resolution that's not the position I want. I need the pixel coordinate of Row 24. Anyone?

Thanks a million.


I have just moved over to Excel 2007 (from 2003) and need help please.

When I manually adjust the column width, or row height, the very useful label showing the width value doesn't appear.

I've gone through the options but can't find where the control is for this function. Can someone please tell me how to turn this back on. I would like to know the width value without having to go to the Column Width... option.

Cheers, Richard.


Greetings Board,

XL 2003, Windows XL Pro

I'm working on a database project and need to match it to an existing XL sheet.

Is there any way to default XL to work with column widths (and row heights) in pixels.

In other words, if I set a width to 10, I would want it to set to 10 pixels. I know the screen will show me the pixel count if I drag and drop, but I want to be able to set the widths and heights.

Thank you.


Hi,

I am not sure what units the below numbers are in . Is it pixels? The chart properties are usually in inches. example : height is 3.47 and width is 5.3 inches.

But what is the corresponding units when we assign a number to the width and height in the vba code? Any help is appreciated.

Thanks!

' Resize:
sr.Width = awidth
sr.Height = aheight
sr.LockAspectRatio = lockaspect

If sr.Width > 500 Then
sr.Width = 500
End If
If sr.Height > 250 Then
sr.Height = 250
End If


In my worksheet-application I have to display height/width in particular cells for some rows/columns. Unfortunately I cannot find (Excel 2007) any possibility that Excel application could hand over control to any macro direct the event occur. My work around solution is - after changing height/width I delete the old value and use the 'Worksheet_Change' event to run a macro that put a new value.
Is there any quicker and simpler way to do the task?

Hello,
I would like to set the Row height of select Rows from A1 and select Columns from A2.
There maybe different sizes of Rows or Columns in between.

Please advise,
Harry


Hi,
How can I in Excels WorkSheet objects such as PlotArea or Shape using VBA and API determine pixel color at given coordinates. API function GetPixel requires handler - hdc so do Excels objects possess hdc and how can I get it? Or maybe there is another way to read pixel color ?


I want to make the width of some of my rows 30mm. When I select row height, I enter 30 in the pop-up box but, the printed row is not 30mm. What does the number in the box represent and how do I set my rows (and columns) to exact sizes?


When you use a font size or you want to set column width or row height,is the text given in pixels?

What kind of a unit is that?A pixel of what size?Can't you set the units into cm,m,in or anything of real world value,for printing purposes?