LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Macro Import Excel Sheet into Excel Sheet

Well I followed the steps you outlined and recorded it.
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/12/2007 by Peter Richardson
'

'
Sheets("data").Select
Cells.Select
Range("A10").Activate
Selection.ClearContents
Range("A1").Select
Workbooks.Open Filename:= _
"C:\Documents and Settings\par\My Documents\fixed calls.xls"
Columns("A:AA").Select
Selection.Copy
Windows("Book1").Activate
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub

A couple quick changes and I ended up with:
Sub Macro2()
Dim currRow As Long
Sheets("data").Select
Cells.Select
Selection.ClearContents
Workbooks.Open Filename:="fixed calls.xls"
Columns("A:AA").Select
Selection.Copy
Windows("Book1").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
For currRow = ActiveSheet.UsedRange.Row To ActiveSheet.UsedRange.Row +
ActiveSheet.UsedRange.Rows.Count
Cells(currRow, 28) = "=sum(A" & currRow & ":AA" & currRow & ")"
Next
End Sub


This should give you a starting place.

"Paul Dennis" wrote:

yes I use the recorded sometimes but I don't see how it would help me here.

Is there a macro somewhere that does something similar that I can use as a
starting point?

"barnabel" wrote:

This is not a difficult task to write. If you want to learn to write macros
the easiest way is to use the macro recorder and record doing it once. then
look at the code the recorder makes. It does not write the best code but it
will give you a good start. From there you can modify it to do exactly what
you want.

Even after years of programming Excel Sometimes I have to use the macro
recorder to see how it will do something and get pointers to how to do it.

Peter Richardson

"Paul Dennis" wrote:

I have an Excel Workbook, with sheets Intro and Data.

I am trying to write a macro that will
. Clear data in sheet [Data]
. Open another excel file in the same directory called "Fixed Calls.xls" and
copy the data from sheet [Sheet1] column A to AA to the current workbook
sheet [Data] columns A to AA.
. Add a new field in column AB for all rows used that will add Z to A

I'm a novice so I don't even know how to do the import without using a
WebQuery, however I want to do this via a macro.

any ideas?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
import data from previous sheet in excel gasman Excel Discussion (Misc queries) 1 December 13th 09 01:15 PM
Export sheet store sheet import sheet. Robert[_33_] Excel Programming 0 December 28th 06 01:58 PM
Import more than one sheet into excel Chuck Excel Discussion (Misc queries) 2 January 27th 06 03:41 PM
How can I import a website into my excel sheet automatically ever. Mohamed El Hefnawy Excel Discussion (Misc queries) 2 April 13th 05 04:51 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


All times are GMT +1. The time now is 05:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"