Results 1 to 9 of 9

Thread: Please Help!!.

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    9

    Please Help!!.

    I have written some VB code to select a named range, copy it open another workbook and paste (special values) into it - starting at the first blank cell it comes across. I cannot get it working right, can anyone help??

    Thanks very much

  2. #2
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,470

    Re: Please Help!!.

    you need to show some code so that we can help

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    9

    Re: Please Help!!.

    Sub ExportAgain()
    '
    ' ExportAgain Macro

    ' append

    ActiveWorkbook.Unprotect "nhp2012"
    Sheets("EXPORT").Visible = True
    Application.Goto Sheets("Export").Range("ExportRange")
    Selection.Copy
    Workbooks.Open Filename:="F:\HOME\COMMERCIAL\SMALL GROUP RATE MODELS\ACCT_DATA_STORE_2012.xlsx", _
    Password:="nhp2012", WriteResPassword:="nhp2012"


    If Range("A2").Value = "" Then
    Range("A2").Select

    Else
    Range("A1").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).Select

    End If
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False


    Application.CutCopyMode = False
    ActiveWorkbook.Save
    ActiveWindow.Close
    Sheets("Export").Select
    ActiveWindow.SelectedSheets.Visible = False
    ActiveWorkbook.Protect "nhp2012"
    ActiveWorkbook.Protect Structure:=True, Windows:=False
    ActiveWorkbook.Save


    End Sub

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Please Help!!.

    I cannot get it working right, can anyone help??
    what happens?
    error?
    wrong result?
    nothing?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    9

    Re: Please Help!!.

    I get a Microsoft Visual Basic error that just says '400'?

  6. #6
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,470

    Re: Please Help!!.

    the error appears to be about something that does not exist..

    you need to fill your code with stops and identify where the error comes from

    here to help

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    9

    Re: Please Help!!.

    I am new to this, please help me with it. How do I put stops into the code?

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Please Help!!.

    I get a Microsoft Visual Basic error that just says '400'?
    on which line?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  9. #9
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Please Help!!.

    Re. "How do I put stops in code?"

    You literally just type "stop" in any available line of code. I would suggest right at the start of your sub, like this:

    Code:
    Sub checkIt()
        Stop
        Dim myValue As Integer
        myValue = Cells(3, 5)
        'other code...
    End Sub
    Then, once it goes into "break" mode, you can hit F8 to advance one line of code at a time.

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