473,624 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel.Range.Pas te 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,x lsB,xlsC;
_book2 = OpenExcelWorkbo ok(@"C:\PRPTemp .xls");
_sheet2 = (Excel.Workshee t)_book2.Active Sheet;
_sheet2.Select( Type.Missing);
Excel.Worksheet _sheetTemp =
(Excel.Workshee t)_book2.Worksh eets[1];
xlsManip = _sheetTemp.Used Range;
for (int i = 1; i <= xlsManip.Rows.C ount; i++)
{
xlsA = _sheetTemp.get_ Range("A" + i.ToString(),
Type.Missing);
xlsC = _sheetTemp.get_ Range("C" +
i.ToString(),Ty pe.Missing);
if(xlsA.Value!= null)
{
xlsA.Copy(Type. Missing);

xlsC.PasteSpeci al(Excel.XlPast eType.xlPasteAl l,Excel.XlPaste SpecialOperatio n.xlPasteSpecia lOperationNone, Type.Missing,tr ue);
}
}
xlsA =
_sheetTemp.get_ Range("A1",Type .Missing).Entir eColumn;

xlsA.Delete(Exc el.XlDeleteShif tDirection.xlSh iftToLeft);

_sheet2.SaveAs( @"C:
\PRPTemp1.txt", Excel.XlFileFor mat.xlTextWindo ws,Type.Missing ,Type.Missing,T ype.Missing,Typ e.Missing,Type. Missing,Type.Mi ssing,Type.Miss ing);
}
catch(Exception Ex)
{
MessageBox.Show (Ex.Message);
}
}
Macro code
---------------
Sub Test()
'
' Test Macro
' Macro recorded 6/15/2007 by shsen
'

'
Range("A1").Sel ect
ActiveWindow.Sm allScroll Down:=69
Range("A1:A88") .Select
Selection.Copy
ActiveWindow.Sm allScroll Down:=-93
Range("C1").Sel ect
Selection.Paste Special Paste:=xlAll, Operation:=xlNo ne,
SkipBlanks:=Fal se _
, Transpose:=True
Range("B1").Sel ect
ActiveWindow.Sm allScroll Down:=66
Range("B1:B88") .Select
Application.Cut CopyMode = False
Selection.Copy
ActiveWindow.Sm allScroll Down:=-96
Range("C2").Sel ect
Selection.Paste Special Paste:=xlAll, Operation:=xlNo ne,
SkipBlanks:=Fal se _
, Transpose:=True
Columns("A:B"). Select
Application.Cut CopyMode = False
Selection.Delet e Shift:=xlToLeft
Range("C2").Sel ect
End Sub

Jun 18 '07 #1
0 7267

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

Similar topics

13
3238
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 know this for sure yet...) I definitely need to get this data in Access and get it normalized. (sigh ....) The data is so 'nice' for the Import- and TransferSpreadsheet-wizard that the 'wizard' really chokes on it ;-) Either the data is not...
1
7789
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 ("B7").pastespecial (.xlpastetype.xlpastevalues) end with
5
1552
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 values (two columns, S7:T101) from a sheet(INTERACTION-RF_Calc) in a different sheet (RF-Calculation). In the destiantion sheet a calculation will take place for which the result will be created in cell (H13). Now I need to copy/pasted this results back...
4
3125
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 Range("A2:H2").Select If Range("C2").Value < (Date + 6) And Range("E2").Value < 10 Then Selection.Copy Sheets("SCHEDULE").Select Range("A8:H8").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,...
10
3111
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
1254
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 to be Access Database Query which pulls data from an SQL Server DB - when there is an ODBC Failure - all other reports that are scheduled get hung up - is there a way to force the application to quit if there is an ODBC Failure/Timeout? Or any other...
0
974
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 most helpful!! Here is the code I am working with. Sub Update1() ' ' Macro4 Macro ' Dim SaveString As String Dim sstr As String Dim pptr As String
2
6411
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 net. It copies the data in each chart/datasheet and slide in powerpoint but I'm struggling with the bit to get the data into excel. Below it I've tried incoporating some code to paste into excel but it does not seem to work. Hope someone can...
5
12579
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 cannot be pasted because the copy area and the paste area are not the same size and shape". Does this function only work if the number or rows and number of columns are the same number? Does anyone have any suggestions for me? I greatly appreaciate...
0
8233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.