LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Is my VBA wrong???

Hi all

I have created a master spreadsheet which I have written a code for in order
to:

1. Delete all contents except the first row, which I have written as :

Sheets("Data").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("a2").Select


2. It will look at the file path and file name (as the original files are
saved in the same foler on a monthly basis), and then select and copy all the
data within the specified file path and paste it onto my master spreadsheet,
which looks like this:

qpath = [D14].Value: qfile = [D15].Value

'Opening workbook specified within the worksheet and copy all data
Workbooks.Open(qpath & qfile).Activate
Sheets("Sheet1").Select
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Corporate File Preparation").Activate
Sheets("Data").Select
Range("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Windows(qfile).Activate
Range("A2").Select
ActiveWorkbook.Save
ActiveWorkbook.Close
Windows("Corporate File Preparation").Activate
Sheets("Control").Select
Range("B2").Select

Eventually I have inserted a few columns at the end of the data for date
stamp and other forumlas as well.

However, my problem arises when I copy this module into other master
spreadsheets, the formats and data are all different between them so what I
did was to change the file paths and some of the formulas. Everything works
perfectly, except when I link these master spreadsheets to Access, which is 8
in total, 7 of them are incorrect, due to the original module I written for
consists of 27 columns (included 3 columns i have added in using vba) and 853
rows of data. The other spreadsheets have less columns and less rows of data,
excel looks fine, but in Access, many blank rows and columns are also
imported up to 27 columns and 853 rows. I am not sure what I need to do here
as I will have to append these sets of data to another table in Access, it
also append those are blank too.

I think it's because my vba are written incorretly in Excel, or is it
something to do with linking the tables in Access?

Please help as I am very stuck here!!!

Thanks a lot any help will be appreciated!!!

Regards

Vivian

 
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
what is the wrong? rajaiy Excel Worksheet Functions 0 July 27th 09 11:45 AM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
What is going wrong here... [email protected] Excel Programming 0 December 1st 06 01:22 PM
what am i doing wrong short_n_curly[_12_] Excel Programming 7 July 13th 05 06:34 PM
Where am I going wrong? Pank Excel Discussion (Misc queries) 2 July 13th 05 01:05 PM


All times are GMT +1. The time now is 06:36 AM.

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"