This post will introduce you to two methods of converting a range of cells to an image in Excel. The method involves using the “Copy As Picture” feature in Excel and a VBA code to export the copied range as an image file.
Convert Cells Range to Image Using Copy as Picture Feature
If you want to convert a range of cells to an image in Microsoft Excel Spreadsheet, you can use the built-in “Copy As Picture” feature. Here are the steps:
Step1: Select the cells range that you want to convert to an image.
Step2: Press the “Ctrl + C” shortcut on your keyboard to copy the cells range to the clipboard.
Step3: Click on the “Home” tab in the ribbon. Click on the “Copy” dropdown arrow in the “Clipboard” group, and then select “Copy as Picture“. The Copy Picture dialog box will open.
Step4: In the “Copy Picture” dialog box, select the “As shown on screen” option and the “Picture” format. Click on the “OK” button.
Step5: Now you can paste the copied cells range as an image in another location. For example, you can open an image editor (such as Microsoft Paint), and press the “Ctrl” and “V” keys on your keyboard to paste the image.
Convert Cells Range to Image with VBA Code
You can also use VBA code to automate the process of converting a range of cells to an image. Just do the following steps:
Step1: Open your workbook that contains the range of cells you want to convert to an image.
Step2: Press Alt + F11 to open the Visual Basic Editor.
Step3: In the Visual Basic Editor, click on Insert > Module to create a new module.
Step4: Copy the below VBA code and paste it into the new module.
Sub ConvertRangeToImage_excelgeek() Dim MyChart As ChartObject Dim MyRange As Range Dim DestPath As String Dim FileName As String Set MyRange = Application.InputBox("Select the range of cells:", Type:=8) MyRange.CopyPicture xlScreen, xlPicture Set MyChart = ActiveSheet.ChartObjects.Add(0, 0, MyRange.Width, MyRange.Height) MyChart.Activate MyChart.Chart.Paste DestPath = Application.GetSaveAsFilename(InitialFileName:="MyImage", _ FileFilter:="PNG Files (*.png), *.png, JPEG Files (*.jpg), *.jpg, GIF Files (*.gif), *.gif, BMP Files (*.bmp), *.bmp", _ Title:="Save As") If DestPath <> "False" Then FileName = Mid(DestPath, InStrRev(DestPath, "\") + 1) MyChart.Chart.Export DestPath, Mid(DestPath, InStrRev(DestPath, ".") + 1) End If MyChart.Delete End Sub
Step5: Save the module and close the Visual Basic Editor. Press Alt + F8 to open the Macro dialog box.Select the ConvertRangeToImage_excelgeek macro from the list of available macros and click Run.
Step6: select the range of cells you want to convert to an image.
Step7: The code will prompt you to choose the destination folder and image name for the converted image.
Step8: Once you select the destination folder and image name, the code will export the range of cells as an image file in the selected format.
With the above methods, you can easily convert any range of cells in your Excel worksheet to a PNG, JPG or other image format, which can be useful for sharing data, creating reports, or including the data in a presentation.