473,289 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Excel.Range.Paste Special - Transpose not working

I am trying to convert a macro code to c# that will copy the values of
a column and paste to anather through paste special. Everything is
working fine but the transpose meathod to paste the column value as
row value is not working. Can someone kindly look into the code, if i
am missing something.

C# Code
------------
private void ManipulateXLS()
{
try
{
Excel.Range xlsManip,xlsA,xlsB,xlsC;
_book2 = OpenExcelWorkbook(@"C:\PRPTemp.xls");
_sheet2 = (Excel.Worksheet)_book2.ActiveSheet;
_sheet2.Select(Type.Missing);
Excel.Worksheet _sheetTemp =
(Excel.Worksheet)_book2.Worksheets[1];
xlsManip = _sheetTemp.UsedRange;
for (int i = 1; i <= xlsManip.Rows.Count; i++)
{
xlsA = _sheetTemp.get_Range("A" + i.ToString(),
Type.Missing);
xlsC = _sheetTemp.get_Range("C" +
i.ToString(),Type.Missing);
if(xlsA.Value!=null)
{
xlsA.Copy(Type.Missing);

xlsC.PasteSpecial(Excel.XlPasteType.xlPasteAll,Exc el.XlPasteSpecialOperation.xlPasteSpecialOperation None,Type.Missing,true);
}
}
xlsA =
_sheetTemp.get_Range("A1",Type.Missing).EntireColu mn;

xlsA.Delete(Excel.XlDeleteShiftDirection.xlShiftTo Left);

_sheet2.SaveAs(@"C:
\PRPTemp1.txt",Excel.XlFileFormat.xlTextWindows,Ty pe.Missing,Type.Missing,Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing);
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
Macro code
---------------
Sub Test()
'
' Test Macro
' Macro recorded 6/15/2007 by shsen
'

'
Range("A1").Select
ActiveWindow.SmallScroll Down:=69
Range("A1:A88").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-93
Range("C1").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True
Range("B1").Select
ActiveWindow.SmallScroll Down:=66
Range("B1:B88").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=-96
Range("C2").Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, Transpose:=True
Columns("A:B").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("C2").Select
End Sub

Jun 18 '07 #1
0 7228

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Arno R | last post by:
Hi all, I will have to handle a lot of really 'nice' data in a LOT of Excel sheets. It is all about music files (Billboard top 100) I am afraid there really is a sheet for every year ... (Don't...
1
by: adrian | last post by:
hello! i have a problem in pasting the content of a cell into another. i have tried it with the following code: excel = createobject ("excel.application") with excel .range...
5
by: sotsigo | last post by:
Hi there, I am a quite unexperienced VB user and I am trying to do some simple operations in excel. I am presenting my existing problematic code below. I am trying to copy/paste a range of...
4
by: keithsimpson3973 | last post by:
Hi. I am trying build an array in vb applications for excel. I am posting the code for what I am trying to write. Any help would be appreciated greatly.. Sheets("C16-M-001").Select ...
10
by: Esmael | last post by:
Hi to all, /*****************************/ OS-WIn XP SP2 VB6 SP6 /*****************************/ Is their anyone who can help me with this: Source code written on VB6.
0
by: scolivas | last post by:
I don't know if this is the right place to ask or not...so here it goes... I have an excel spreadsheet with a macro that refreshes data which is pulled from an external data source, which happens...
0
by: semme001 | last post by:
I have a macro that ran normally for about 6 cycles but apparently developed an error? It appears to stall on the second loop when it attempts to open the named workbook. Any suggestions would be...
2
by: LucasLondon | last post by:
Hi, I'm trying to use VBA to extract underlying data from charts in powerpoint to excel, i.e from the underlying powerpoint datasheet that feeds the chart. I've found the macro below on the...
5
by: jenniferhelen | last post by:
I have been searching threads for a while and found the instructions listed below many times, however when I get to step 6 and select to save, I always receive the following error, "The information...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.