+ Reply to Thread
Results 1 to 2 of 2

need for code help

  1. #1
    Registered User
    Join Date
    05-19-2014
    Posts
    2

    need for code help

    am new in vba, i create code buy sell value based copy paste in new workbook ,same action in 30 rows, when i put this code (this code one row exmple only ) for 30 rows in worksheet calculate , excel was hanged and restart, kindly help, (this code row 2 only, its countine up to row 30,)

    Private Sub Worksheet_Change(ByVal Target As Range)
    If (Range("H2") >= Range("B2")) Then
    Range("I2") = "BUY"
    Range("AA2:AU2").Copy
    Workbooks.Add
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Fsn = ActiveCell.Range("C1")
    ActiveWorkbook.SaveAs Filename:="C:\ORD\BUY\" & Fsn & "_BUY_CALLS_@" & Format(Now, "mm-dd-yyyy-hh-mm") & ".CSV", _
    FileFormat:=xlCSV, CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False


    Range("BA2:BU2").Copy
    Workbooks.Add
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Fsn = ActiveCell.Range("C1")
    ActiveWorkbook.SaveAs Filename:="C:\ORD\BUY\SL\" & Fsn & "_BUY_SL_ORDER_@" & Format(Now, "mm-dd-yyyy-hh-mm") & ".CSV", _
    FileFormat:=xlCSV, CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False

    Range("CA2:CU2").Copy
    Workbooks.Add
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Fsn = ActiveCell.Range("C1")
    ActiveWorkbook.SaveAs Filename:="C:\ORD\BUY\TGT\" & Fsn & "_BUY_TGT_ORDER_@" & Format(Now, "mm-dd-yyyy-hh-mm") & ".CSV", _
    FileFormat:=xlCSV, CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False

    End If
    ElseIf (Range("H2") <= Range("E2")) Then
    Range("i2") = "SELL"
    Range("DA2:DU2").Copy
    Workbooks.Add
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Fsn = ActiveCell.Range("C1")
    ActiveWorkbook.SaveAs Filename:="C:\ORD\SELL\" & Fsn & "_SELL_CALLS_@" & Format(Now, "mm-dd-yyyy-hh-mm") & ".CSV", _
    FileFormat:=xlCSV, CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False
    'ActiveWorkbook.Saved = True
    ' MsgBox "NEW_" & Range("a2") & "_SELL CALLS ACTIVE"

    Range("EA2:EU2").Copy
    Workbooks.Add
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Fsn = ActiveCell.Range("C1")
    ActiveWorkbook.SaveAs Filename:="C:\ORD\SELL\SL\" & Fsn & "_SELL_SL_ORDER_@" & Format(Now, "mm-dd-yyyy-hh-mm") & ".CSV", _
    FileFormat:=xlCSV, CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False

    Range("FA2:FU2").Copy
    Workbooks.Add
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Fsn = ActiveCell.Range("C1")
    ActiveWorkbook.SaveAs Filename:="C:\ORD\SELL\TGT\" & Fsn & "_SELL_TGT_ORDER_@" & Format(Now, "mm-dd-yyyy-hh-mm") & ".CSV", _
    FileFormat:=xlCSV, CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=False
    End If
    End If
    End Sub

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: need for code help

    Pls take some time to read forum rules. In your previous thread i warned you for that.

    So:

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    ALSO:

    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)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ 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. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  2. Replies: 2
    Last Post: 12-17-2013, 11:51 AM
  3. Replies: 2
    Last Post: 03-09-2013, 04:30 AM
  4. Adding Text to another cell VB code (Help Tweeking code) (Excel 2007)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 11:37 AM
  5. Replies: 0
    Last Post: 10-06-2006, 09:05 AM

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