Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 13th, 2007, 09:59 AM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help in copying some row and coloums to a file

Hi all;
i am a bit new to VBA.I am in a situation where I have to copy certain parts of a sheet for example A2:B300 to a file in C:.Is it possible?I did see some posts on copying a sheet which gives some hope.If any one knows how to do it,plz help any ideas are welcome:D
 
Old March 15th, 2007, 02:01 AM
Registered User
 
Join Date: Feb 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

paste below code in VBA window
----------------------------------
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 3/15/2007 by DPS
Dim R As Integer
Dim strName As String, lngBasic As Long
Open "c:\ExcelTxt.txt" For Output As #1
For R = 2 To 300

    Range("A" & R).Select
    strName = ActiveCell.FormulaR1C1

    Range("B" & R).Select
    lngBasic = ActiveCell.FormulaR1C1
    Print #1, strName, lngBasic
    'REMOVE BELOW LINE AND CHECK RESULT FILE
    Write #1, strName, lngBasic
Next R
Close #1
MsgBox "OK"
End Sub
------------------------------
Regards
Ketan N Sharma
 
Old March 15th, 2007, 03:05 AM
Registered User
 
Join Date: Mar 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Ketansharma;
I modified the one u gave me and it works.Thnx a lo:D





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying and connecting to a file metal2000man BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 May 31st, 2006 12:35 PM
image file copying! heerajee Pro PHP 2 March 22nd, 2006 06:19 AM
copying file from one machine to other CsharpHelp C# 0 October 23rd, 2005 05:22 AM
copying the file from one machine to other CsharpHelp C# 0 October 23rd, 2005 05:20 AM
Copying a File, How? xgbnow Visual C++ 3 September 16th, 2003 03:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.