+ Reply to Thread
Results 1 to 7 of 7

Checking the Syntax Errors in the Excel Sheet Using Macro

  1. #1
    Registered User
    Join Date
    06-04-2012
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    5

    Checking the Syntax Errors in the Excel Sheet Using Macro

    Hi Everybody

    i have to write a macro to handle the errors in the 'D1' Sheet when im copy & pasting a new sheet.
    Please check the sheet attached.

    Please help me in some functions at least how can i handle those errors.



    Thanks in Advance
    Sunil.k
    Attached Files Attached Files
    Last edited by kollurusk; 06-05-2012 at 05:25 AM. Reason: Error list fully updated in excel sheet

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Error Handling Rules when copy pasting new sheet using Macro

    You need to explain some more. Your question is not clear.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-04-2012
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Error Handling Rules when copy pasting new sheet using Macro

    Hi

    Please see the macros below examples

    1)checking cell value is blank or numeric or string..if its a string im checking there is "Space" or "p" or "D" found in string displaing a error message and changing the color as red color


    Sub macro1()

    Dim sheet1 As Worksheet

    Dim disb1 As Variant

    Dim i As Integer

    Dim j As Integer

    Dim myarray As Variant

    i = 1
    j = 1
    k = 4

    myarray = Array("D", " ", "p")

    For j = 1 To 8

    disb1 = Sheets("sheet1").Cells(k, j).Value

    If (IsEmpty(disb1)) Then
    MsgBox ("Cell Value is blank: Blank " & disb1)
    ElseIf (IsNumeric(disb1)) Then
    MsgBox ("Cell Value is Numeric: " & disb1)
    Else
    For l = 0 To UBound(myarray)
    FindChar = myarray
    SearchString = Sheets("sheet1").Cells(k, j).Value
    For i = 1 To Len(SearchString)
    If Mid(SearchString, i, 1) = FindChar(l) Then
    Pos = i
    MsgBox " Array Value Was Found in the String at Position: " & Pos
    Sheets("sheet1").Cells(k, j).Select
    Selection.Interior.ColorIndex = 3
    MsgBox ("String is : " & SearchString)
    End If
    Next i
    Next
    End If
    Next

    End Sub


    Like that i want to handle all the errors in a macro what im commented in excel sheet attached.
    Each error handling we can develop as a function.

    Thanks
    sunil.k

  4. #4
    Registered User
    Join Date
    06-04-2012
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Error Handling Rules when copy pasting new sheet using Macro

    Please check the attached test file
    Attached Files Attached Files

  5. #5
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Error Handling Rules when copy pasting new sheet using Macro

    You don't need error handling, you need to fix the syntax errors in your code. what exactly are you trying to do?
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Error Handling Rules when copy pasting new sheet using Macro

    kollurusk,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Error Handling Rules when copy pasting new sheet using Macro

    Fisrt add code tags to your previous post.

    Start using Option Explicit to help detect such errors

    Don't add error handling when the problem can be resolved.

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Registered User
    Join Date
    06-04-2012
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Error Handling Rules when copy pasting new sheet using Macro

    Hi

    Thanks for correcting me...i changed the subject line...
    first of all im going to developing the each syntax error as each macro after that i want to develop a complete macro using functions to check all the syntax errors for each cell in excel sheet....correct me may be i am wrong...
    please help me how to check the formula contain only these operators and stings they are a "*", "-","/","+", min, max, round, roundup, rounddown only ..this syntax error also i have added in my excel comments...

    Ex: round(([disb1]*([Param1]/100)), 2)
    Last edited by kollurusk; 06-05-2012 at 06:43 AM. Reason: added example formula

  9. #9
    Registered User
    Join Date
    06-04-2012
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    5

    declaringa a arry and calculated the formula in cell

    in my excel sheet all the cells having the formulas like this how can i declare a array

    after calculation the cell value is displayed with value
    ex: disb1 = 162 and param1 =100

    round(([disb1]*([Param1]/100)),2)

    please help me how to declare a array and how to calculate the formula

    thanks in advance
    sunil.k

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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