Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:29:10+00:00 2026-06-06T08:29:10+00:00

I have an Excel spreadsheet that I have exported from some other program. It

  • 0

I have an Excel spreadsheet that I have exported from some other program.

It has rows that are colored based on few business conditions.

Now I have to transpose the whole excel sheet along with the colors and formatting.

Please note that I have to do this using Vbscript only.

This is the code I’ve written so far, but this transposes without the formatting:

 sub transpose
 On Error Resume Next
 Set objExcel = CreateObject("Excel.Application")
 objExcel.Visible = False
 objExcel.Workbooks.Add()
 set table = ActiveDocument.GetSheetObject( "CH01" )
 CellRect = ActiveDocument.GetApplication().GetEmptyRect()
 CellRect.Top = 0
 CellRect.Left = 0
 CellRect.Width = table.GetColumnCount
 CellRect.Height = table.GetRowCount
 set CellMatrix = table.GetCells( CellRect )
 for RowIter=CellRect.Top to CellRect.Width-1
   for ColIter=CellRect.Left to CellRect.Height-1
     ObjExcel.Cells(RowIter+1, ColIter+1).Value = CellMatrix(ColIter)(RowIter).Text
    'msgbox(CellMatrix(ColIter)(RowIter).Text)
   next
 next
 objExcel.ActiveWorkbook.SaveAs("C:\Documents and    Settings\prasanna\Desktop\test3.xls")
 objExcel.Application.Workbooks.Open("C:\Documents and           Settings\prasanna\Desktop\test3.xls")
 objExcel.Application.Visible = True
 objExcel = Nothing
 end sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:29:13+00:00Added an answer on June 6, 2026 at 8:29 am

    Phew.., this costed some time and experimenting, here a working solution for office 2012

    const xlPasteValuesAndNumberFormats = 12 'doesn't work with Excel 2010 ?
    const xlFormats =-4122
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    objExcel.DisplayAlerts = false
    

    if you allready have your target xls you can skip these lines

    Set wbkDest = objExcel.Workbooks.Add
    wbkDest.saveAs "c:\test2.xls"
    wbkDest.close
    

    and go on here

    Set objWorkbook1= objExcel.Workbooks.Open("C:\test1.xls")
    Set objWorkbook2= objExcel.Workbooks.Open("C:\test2.xls")
    objWorkbook1.Worksheets("Sheet1").UsedRange.Copy
    'we have to do the paste twice, once for the values, once for the formats
    objWorkbook2.Worksheets("Sheet1").Range("A1").PasteSpecial xlPasteValuesAndNumberFormats
    objWorkbook2.Worksheets("Sheet1").Range("A1").PasteSpecial xlFormats
    objWorkbook1.save
    objWorkbook2.save
    objWorkbook1.close
    objWorkbook2.close
    set objExcel=nothing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data in an Excel spreadsheet that has 10,000 rows with the following
I have an excel spreadsheet that has about 18k rows and three columns. I
I have an excel spreadsheet that has two columns. When I choose to save
I have an excel spreadsheet that has dates in the first column, the rest
i have an excel spreadsheet that is about 300,000 rows and about 100 columns
I have a sharepoint site that has an excel spreadsheet that I need to
I have a list of header values from an excel spreadsheet that is set
I have an excel spreadsheet that has 2 columns. Something like this |ColA |
I have an Excel spreadsheet that needs to display data from our SQL database.
I have data from an Excel spreadsheet that I want to import into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.