ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   reading database and filling excel (https://www.excelbanter.com/excel-programming/315794-reading-database-filling-excel.html)

Bob

reading database and filling excel
 
Hi,

I'm trying to read from SQL server and create a Excel report from it. I can
do this by exporting data function. However I need to place up to 3 clip arts
in the first column on this report based on the condition in the another
cells and also change the background color for the entire row.
I can insert the image, but I have problem with resizing the cell based on
the images and also checking to see if the ccell already have the image then
do not insert again.
Here is my code I used so far:

Sub Macro1()
'
Dim TotalRows As Integer

TotalRows = ActiveSheet.UsedRange.Rows.Count
For i = 1 To TotalRows
If Range("C" & (i + 4)) = "Y" Then
ActiveSheet.Shapes("Picture 1").Select
Selection.Copy
Range("A" & (i + 4)).Select
ActiveSheet.Paste
' Selection.Rows.AutoFit
' Selection.Columns.AutoFit
For Each sht In ActiveWorkbook.Worksheets
sht.Columns("A:A").EntireColumn.AutoFit
Next sht
End If
Next
I would appreciate your feed back on this issue.

Regards,
Bob
End Sub


All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com