LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default HOW TO PUT MSGBOX CODE IN MACRO

Hi all, Please see the macro below which is sent to me by one of
online friend

Sub MultAmt()
Const x = 12
Dim i As Integer
Dim LRow As Long
Dim rng As Range, c As Range
Dim rng2 As Range, c2 As Range

LRow = Sheets("FORM").Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Sheets("FORM").Range("D2:D" & LRow)
LRow = Sheets("RESULT BY MACRO").Cells(Rows.Count, "A").End(xlUp).Row
If LRow = 1 Then
'do nothing
Else
Sheets("RESULT BY MACRO").Rows("2:" & LRow).Delete
End If
i = 1
For Each c In rng
LRow = Sheets("RESULT BY MACRO").Cells(Rows.Count,
"A").End(xlUp).Row
c.EntireRow.Copy Sheets("RESULT BY MACRO").Range("A" & LRow +
i & ":A" & LRow + x)
Next
LRow = Sheets("RESULT BY MACRO").Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Sheets("RESULT BY MACRO").Range("D2:D" & LRow)
LRow = Sheets("PERCENTAGES DATA").Cells(Rows.Count, "A").End(xlUp).Row
Set rng2 = Sheets("PERCENTAGES DATA").Range("A3:M" & LRow)
i = 2
For Each c In rng
c.Offset(, 1).Value = c.Offset(, 1).Value * _
(Application.WorksheetFunction.VLookup(c.Value, rng2, i,
False) / 100)
c.Offset(, 3).Value = Sheet1.Cells(2, i).Value
If i = 13 Then
i = 2
Else
i = i + 1
End If
Next
End Sub

my question is that in macro above where it say

For Each c In rng
c.Offset(, 1).Value = c.Offset(, 1).Value * _
(Application.WorksheetFunction.VLookup(c.Value, rng2, i,
False) / 100)

What code should i add which should do the job

if c.Offset(, 1).Value * _
(Application.WorksheetFunction.VLookup(c.Value, rng2, i,
False) / 100) = #N/A Then
Msgbox "not found" & (code number which is not found)
Exit Sub
Else
c.Offset(, 1).Value = c.Offset(, 1).Value * _
(Application.WorksheetFunction.VLookup(c.Value, rng2, i,
False) / 100)

to more understand my question you can check the file which i have
uploaded ( http://www.savefile.com/files/1535694 ) and you can put
the macro above in Module of that sheet. The macro above workes
perfectly fine i just need to know how can i add Msgbox line which i
mention above. Please if any friend can help




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Msgbox Code Help Please.... kmwhitt Excel Discussion (Misc queries) 5 September 21st 06 01:52 AM
Code for MsgBox TimN Excel Programming 3 September 5th 06 05:53 PM
VBA code using if then and msgbox snoopy Excel Discussion (Misc queries) 0 December 1st 05 08:48 PM
Problem with Msgbox Code Old Dog Excel Programming 3 November 23rd 05 01:14 AM
syntax for code in MsgBox()? Ouka[_4_] Excel Programming 2 July 20th 05 05:18 PM


All times are GMT +1. The time now is 10:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"