+ Reply to Thread
Results 1 to 4 of 4

Importing data with vba

  1. #1
    Registered User
    Join Date
    07-29-2009
    Location
    Ireland
    MS-Off Ver
    Excel 365
    Posts
    54

    Importing data with vba

    Hi all,

    i have a script to import a workbook which works fine, but when the data is imported i would like to have all the data in the cells aligned to the left of the cells, as im new to vba i can work this out. if there experts that can help with this?

    Below is the script i'm using to import.

    I would like this to aligned all cells to the left and centered when imported.


    Sub tst()
    With workbooks.open("C:\example.xls")
    with .sheets(1).usedrange
    thisworkbook.sheets(1).cells(rows.count,1).end(xlup).offset(1).resize(.rows.count,columns.count)=.value
    end with
    .close False
    End with
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Importing data with vba

    Try this...

    Please Login or Register  to view this content.
    Regards,
    Rudi

  3. #3
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: Importing data with vba

    BTW: Using Application.ScreenUpdating will prevent the code from flickering on your screen...

    Please Login or Register  to view this content.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,921

    Re: Importing data with vba

    mattless1, your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 07-24-2013, 11:16 PM
  2. Replies: 1
    Last Post: 07-20-2012, 07:08 PM
  3. Excel Import Data not importing entire data set
    By gravine in forum Excel General
    Replies: 1
    Last Post: 02-01-2012, 02:33 PM
  4. Replies: 2
    Last Post: 03-28-2008, 07:08 AM
  5. [SOLVED] Importing data, then adding data to the new spreadsheet.. a conund
    By AndyL82 in forum Excel General
    Replies: 1
    Last Post: 03-09-2006, 06:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1