Results 1 to 6 of 6

Thread: [RESOLVED] Simple but stuck

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    8

    Resolved [RESOLVED] Simple but stuck

    writing in excel 2003
    i am trying to copy and rename an excel workbook but i cant seem so sort it out.
    the dates need to start on 01-01-10 and finish 31-12-10
    the code i have been working on is below. but i cant find out what the problem is???? please help


    Dim nyear As Date

    nyear = Format(Now(), "dd-mm-yy")
    Do Until nyear = "31-12-10"


    FileCopy Source:="M:\settings\Desktop\monthmaster.xls", Destination:="M:\settings\Desktop\" & nyear & ".xls"
    nyear = nyear + 1
    Loop
    End Sub

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Simple but stuck

    Try something like this...
    Code:
    Dim nyear As Date
    
    nyear = DateSerial(2010, 1, 1)
    While nyear <= DateSerial(2010, 12, 31)
        Debug.Print nyear
        FileCopy Source:="M:\settings\Desktop\monthmaster.xls", Destination:="M:\settings\Desktop\" & Format(nyear, "dd-mm-yy") & ".xls"
        nyear = DateAdd("m", 1, nyear) '~~~> adds 1 month (for more info: http://www.vb6.us/tutorials/understanding-vb6s-dateadd-function)
    Wend

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Simple but stuck

    Moved To Office Development

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    8

    Resolved Re: Simple but stuck

    spot on thaky you very much.

    and merry xmas

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Simple but stuck

    spot on thaky you very much.
    Glad to hear that...

    Happy new year...!

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6
    New Member
    Join Date
    Feb 2010
    Posts
    8

    Re: [RESOLVED] Simple but stuck

    I believe I have 2 similar problems

    1. How do I paste my copied cells into workbook "Y"?

    2. The data is pulled from SAP and has a fair amount of information about the data pull at the top of the spreadsheet. The amount of data may vary, making the row I sort on, 56, inappropriate. Is there a way to sort under a specifically named cell(s)?

    This is a hodgepodge of code thrown into one macro, if there is a way to re-tool, please feel free.

    Thank you for the help.


    Code:
     Sub Macro2()
    '
    ' Macro2 Macro
    '
    
    '
        Dim wbbook As Workbook
        Dim thiswbbook As ThisWorkbook
        
        strSecondFile = "Workbook x"
        
        Set wbk = Workbooks.Open(strSecondFile)
        With wbk.Sheets("Sheet1")
        
        Rows("56:56").Select
        Selection.AutoFilter
        ActiveSheet.Range("$A$56:$AC$30015").AutoFilter Field:=3, Criteria1:="XXXX"
        Range("G57:J57").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        
        *GO BACK TO WORKBOOK Y*
        
        Range("FILLDOWN_START_ROWCOUNT").Select
        ActiveSheet.Paste
        Selection.End(xlDown).Select
        ActiveCell.Offset(1, 0).Range("A1").Select
        End With
        
    End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width