Copies data from one Excel spreadsheet to another.
PowerShell$comments = @'
Script name: Copy-ExcelData.ps1
Created on: Wednesday, August 22, 2007
Author: Kent Finkle
Purpose: How can I use Windows Powershell to
Copy Data From One Spreadsheet to Another?
'@
# -----------------------------------------------------
function Release-Ref ($ref) {
([System.Runtime.InteropServices.Marshal]::ReleaseComObject(
[System.__ComObject]$ref) -gt 0)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()
}
# -----------------------------------------------------
$xl = new-object -comobject excel.application
$xl.Visible = $True
$wb = $xl.Workbooks.Add()
$ws = $wb.Worksheets.Item("Sheet1")
$2d = new-object 'object[,]' 20,1
for ($i = 0; $i -le 19; $i++) {
for ($j = 0; $j -le 0; $j++) {
$2d[$i,$j] = $i
}
}
$r = $ws.Range("A1:A20")
$r.Value() = $2d
$a = $r.Copy()
$xl2 = new-object -comobject excel.application
$xl2.Visible = $True
$wb2 = $xl2.Workbooks.Add()
$ws2 = $wb2.Worksheets.Item("Sheet1")
$a = $ws2.Paste()
$a = Release-Ref($ws2)
$a = Release-Ref($wb2)
$a = Release-Ref($xl2)
$a = Release-Ref($ws)
$a = Release-Ref($wb)
$a = Release-Ref($xl)
Verified...
Categories
- All Posts
- android
- AntiVirus
- apps
- AWS
- Backup
- Batch
- Blogger
- Books
- CISCO
- Cloud
- Cluster
- Coin Master
- commands
- Commvault
- Configurations
- CSS
- Data Protector
- Data Recovery
- DB Backup
- Desktop Sharing
- Disabling
- domain
- Downloads
- Dumps
- ESX
- exam questions
- Excel
- Exchange
- FOLDER LOCK
- free Books
- games
- Guide
- Hacks
- HP - UX
- HP0-A113
- HP0-A113 HP ATP - Data Protector v9 (Exam 1 Questions) - Question 9
- HTML
- Hyper-V
- information
- Internet
- interview questions
- inventory
- jQuery
- key
- Links
- Linux or Unix
- Mcafee
- microsoft
- Migrations
- mobile tips
- NetBackup
- Networker
- Networking
- Online Database
- Operating system
- Outlook
- Password reset
- PHP
- Ports
- RAID
- regedit-tips
- Registry
- SAN
- SBS 2008
- Simulator
- software
- SQL
- Storage
- Study Meterial
- tech support
- Tools
- Top List
- Troble Shooting
- Useful commands
- vbscript
- Veeam
- Videos
- Virtual Machine
- VirtualBox
- VMWare
- VSphere
- webinar
- windows
- windows 10
- Windows 2003
- Windows 2008
- Windows 7
- Windows 8
- Windows Tips
- windows XP
- YouTube
Contact
Monday, July 4, 2011
Delete duplicate rows in excel using advanced filter
Tags: delete, Excel, duplicate, rows, filter, advanced filter
Visual Basic'Delete duplicate rows in excel using advanced filter
'Francis de la Cerna
'
'I've been doing this the long way for, well, a long time.
'Sorry, excel, I didn't know you could do that.
set xl = createobject("excel.application")
set wb = xl.workbooks.add
set ws1 = wb.worksheets("sheet1")
set ws2 = wb.worksheets("sheet2")
xl.visible = true
'add some data to sheet1
ws1.range("a1:c1").value = array("a", "b", "c")
ws1.range("a2:c2").value = array( 1 , 2 , 3 )
ws1.range("a3:c3").value = array( 4 , 5 , 6 )
ws1.range("a4:c4").value = array( 7 , 8 , 9 )
ws1.range("a5:c5").value = array( 4 , 5 , 6 )
ws1.range("a6:c6").value = array( 1 , 2 , 3 )
ws1.range("a7:c7").value = array("a", "b", "c")
'filter unique records and copy result in sheet2 starting in cell a1
'i think the 1st row is considered as a header row
xlFilterInPlace = 1
xlFilterCopy = 2
uniqueRecords = true
ws1.range("a1:c7").advancedFilter xlFilterCopy, , ws2.range("a1"), uniqueRecords
Verified...
Computer Hardware Scripts: Retrieving System Information
Retrieving System Information
INVENTORY OF A COMPUTER WITH WINDOWSPripared by Laxman,
Uses WMI to retrieve the same data found in the System Information applet.
======================
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery...
Computer Hardware Scripts: Retrieving BIOS Information
INVENTORY OF A COMPUTER WITH WINDOWS
Pripared by Laxman,
Retrieves BIOS information for a computer, including BIOS version number and release date.
======================strComputer = "."Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colBIOS = objWMIService.ExecQuery _ ...
Identifying Processor Type & Inventorying Computer Hardware
INVENTORY OF A COMPUTER WITH WINDOWS
Pripared by Laxman,
Identifying Processor Type
Determines the processor architecture (such as x86 or ia64) for a specified computer.
========================
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objProcessor = objWMIService.Get("win32_Processor='CPU0'")
If objProcessor.Architecture...
Computer Hardware Scripts: Enumerating Serial Port Properties
INVENTORY OF A COMPUTER WITH WINDOWS
Pripared by Laxman,
Returns information about the serial ports installed on a computer.
==================
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_SerialPort",,48)
For Each objItem in colItems
...
Computer Hardware Scripts: Enumerating Processor Information
INVENTORY OF A COMPUTER WITH WINDOWS
Pripared by Laxman,
Returns information about the processors installed on a computer.
===================
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colItems
...
Computer Hardware Scripts: Enumerating the Physical Memory Configuration
Enumerating the Physical Memory ConfigurationReturns information about the way physical memory is configured on a computer.
INVENTORY OF A COMPUTER WITH WINDOWSPripared by Laxman,
====================
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select...
Enumerating Parallel Port Properties
Enumerating Parallel Port PropertiesINVENTORY OF A COMPUTER WITH WINDOWSPripared by Laxman,
Returns information about the parallel ports installed on a computer.
============================
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ParallelPort",,48)
For...
Computer Hardware Scripts: Enumerating IRQ Settings
Enumerating IRQ Settings
Returns information about the IRQ settings on a computer.
INVENTORY OF A COMPUTER WITH WINDOWS
Pripared by Laxman,
============================================================
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from...
Computer Hardware Scripts: Enumerating Computer Bus Properties.
Enumerating Computer Bus Properties.INVENTORY OF A COMPUTER WITH WINDOWSPripared by Laxman,Returns information about the computer bus.
On Error Resume NextstrComputer = "."Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Set colItems = objWMIService.ExecQuery("Select * from Win32_Bus")For Each objItem in colItems Wscript.Echo "Bus...
Computer Hardware Scripts: Enumerating Computer Baseboard Properties
INVENTORY OF A COMPUTER WITH WINDOWSPripared by Laxman,
Returns information about the computer baseboard.
============================================
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each objItem in colItems
...
Subscribe to:
Posts (Atom)
Upcoming Topics
Search This Blog
Subscribe via email
Weekly
-
Below are some of the frequently asked Storage (SAN)...
-
#NetBackup interview Questions and Answers. I just...
-
Based on my experience in the daily issues level I have...
-
AZ-900 Dumps - Actual exam question and Answers from...
-
AWS Interview Questions And Answers The AWS Solution...
-
Master Server Daemons/Processes Request daemon bprd ...
-
Veeam is a software company that provides data backup...
-
Being a NetBackup backup administrator we should...
-
AZ-900 Dumps - Actual exam question and Answers from...
- NetBackup interview Questions and Answers - Top Rated list - 8/28/2019
- EMC Networker Interview Questions - Top Listed Networker FAQ - 8/28/2019
- Netbackup Cheat Sheet - 6/5/2019
- AWS Interview Questions And Answers - AWS scenario based interview question most asked - Part4 - 4/30/2019
- AWS Interview Questions And Answers - AWS scenario based interview question most asked - Part3 - 4/30/2019