Adding a background image to a particular cell - vba

I tried to insert the background image using following code:
Pic = "C://Picture/Logo1"
Activesheet.SetBackgroundPicture Pic
This inserts the picture to full sheet but I want to add it to particular cell or a range of cells. Please help

As far as I know excel doesn't support appending the image to a cell (with or without VBA).
The background of a single cell supports colors/gradients/fill-patters, but not the pictures.
It is possible however, to "place" the picture (shape) object with the same width and height right above the cell and make it locked and move around together with the cell if somebody attempts to resize cell widths. I personally wouldn't go that way, too much to code and too much risk of breaking the structure.

Related

VBA PowerPoint Table Cell's Format

I have been looking everywhere for this solution but can't seem to find it anywhere.
I want to access these offsets percentage of the cell so I can make the image smaller
But when I use this code
With $SHP.Table.Cell(1, $i).Shape.Fill
.TextureOffsetX = 25
.TextureOffsetY = 25
Endwith
This happens:
Texture tile turns to true and my picture is being repeated itself.

Excel: Background of cell not recognised

Hopefully a quickie.
I have a bizarre case of a cell having a background colour, but excel not recognising it as such.
Upon right click > format cell, no fill is shown, no rgb value assigned to this cell. but the cell is coloured and it can be copied only with VBA's .copy or the Paste Specials Keep Source Formatting and Values & Source Formatting
I would really like to know whats going on, as well as how to edit Tim's code here to copy this colour.
Thank you for your time.
Conditional formatting is not recognized as a background color in VBA.
https://msdn.microsoft.com/en-us/library/office/ff822801.aspx

Add a URL image to a cell where the URL is based on input in another cell

I am moving over a worksheet from GoogleDocs that has to be in Excel now.
It is a barcode generator sheet.
The image cell in GoogleDocs has the formula is
=image("www.somebarcodesite.com/image.php?code=" & A2 & "&style=197&type=C128B&width=300&height=50&xres=1&font=3", 3)
I've downloaded as Excel but that has not helped (I think due to text concatenation) and additional rows may be need to be added so it's not enough to embed the image once when downloading.
I've seen VB solutions to put an image in a cell, but I'm not sure it would allow the users to add new rows to the worksheet.
Does anyone know where I should start on finding a scalable way to show the image generated at a url, where the url is generated dynamically based on the input of other cells?

Assigning a background color to a cell, given a condition on another cell

I am trying to create a formula in Microsoft Excel 2010 to accomplish the following algorithm:
If A1=10, then A2 has a background color of red.
I have basic knowledge of if/then statements in Excel, so I have this so far:
=IF(A1=10, x)
...where x would be the formula for changing the background color of the cell. However, after conducting some internet research on the subject, the consensus seems to be that I should instead use conditional formatting to accomplish this task. I have never used conditional formatting and am having trouble understanding how to utilize it so that a condition on one cell would affect another cell.
This is the conditional formatting screen that I am faced with:
So I guess I have two questions:
Is using conditional formatting the best way to accomplish this?
If so, how can I utilize it to assign a background color to a cell, given the truth of a condition on a different cell?
You can do it using conditional formatting, so you're on the right track. One thing I'm assuming here is that you want to format the cell to the right of the cell with the value - is that correct? If so, you actually don't need to use an if formula (though your logic is correct). In that dialog box, make the formula:
=A1=10
And then when you click OK, change the Applies to range by clicking on the little chart icon next to it and clicking cell B1. Then do apply, etc., close out the box and try typing 10 in A1. When you need to expand the range, you can just change that Applies to range to encompass everything you want affected. In the example below, cells B1:B26 will all change if 10 is entered in the cell directly to the left (column A).

Getting display text as ###### for some of the cell in excel after writing from Vb.net code

I am writting to an excel file from my vb code. The code goes as below
xlsheet3 = xlBook.Sheets.Add(After:=xlSheet)
With xlsheet3
.Columns(5).NumberFormat = "#"
.Cells(j + 1, 5) = someStringValue 'Here "j" is a row counter and this line is in a "for loop"
end with
After writing to excel, most of the cells in excel are correct. But some of the cell's text comes as ####### however if I click on the cell, formula bar shows the correct result. I have tried giving single code before adding the text still that did not help.
Please help me in resolving this.
Thank you
There is not any issue with your code. You need to increase the width of the column or have to use word wrap. In excel if your value is not fully visible it shows it is "######".
If widening and wrapping text doesn't work and the format is set to text which allows display of only 255 characters, try changing the format to general.
This just indicates that the cell is too small for showing the result: make it wider.
See https://superuser.com/questions/65556/excel-displays-for-long-text-whats-wrong for some common reasons why Excel displays "######" in cells.
Either the cell is too narrow to display the contents or the contents are over 256 characters.
Check what you're writing to the cell. If it's not too long then all you need to do is resize the column to fit the new contents.
This is simply what Excel does when the data in a column is too wide to be displayed in the current column width. Make the column slightly wider and you will see all your data.
To autosize the column so it is wide enough to display all its data, double click the column divider at the right edge of the column, in the header bar.