msg box for new record

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
hi all member,
stuck on msg box. i was tryed but i didnt clicked any better idea.
Require your expert solution.
Msg Box should Apperar with msg when -
a new data added in my col A, say A9.
Msg bOx = "Do you want to add new record?" , vbyesno, "Added Record"
if "Yes"
Record will add in cell A15.
After adding record succesfully,
Msg box "New record Added", vbokonly, msg box exit.
Now, here counter i want to put...say,
if A15 <>"" then
When user try to add new record it should go A16.and going on for every new record.
if "No" msg box exit.
aLL VBA masters and members, request you to have look on this, for ur expert solution.
:eeek:
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Maybe this could give you an idea...
Code:
Function AddRecord()
Application.ScreenUpdating = False
Application.EnableEvents = False
With WorksheetFunction.Application
Set myR = Range("B:B")
lrow = Cells(Rows.Count, "B").End(xlUp).Row
'For i = 2 To lrow
Search:
prompt = "Enter New Record"
Title = "New Record"
addrec = InputBox(prompt, Title)
'MsgBox addrec
If addrec = "" Then
'MsgBox "Please enter a Record"
'GoTo Search
Exit Function
Else
For i = 2 To lrow
If Not IsError(.Index(myR, .Match(Val(addrec), myR, 0), 1)) = True Then
'MsgBox "Found"
ans = MsgBox("Record already exist. Do you want to overwrite existing?", vbYesNo, "Record Found")
If ans = vbYes Then
Range("B" & .Match(Val(addrec), myR, 0)).Value = Val(addrec)
updval = InputBox("Enter new value:", "New Value")
Range("C" & .Match(Val(addrec), myR, 0)).Value = Val(updval)
MsgBox "Record: " & "[" & addrec & "]" & " successfully created.", vbInformation + vbOKOnly, "AddNew"
Exit For
Else
GoTo Search
End If
Else
lstrow = lrow + 1
Range("B" & lstrow).Value = Val(addrec)
updval = InputBox("Enter Value:", "New Value")
Range("C" & .Match(Val(addrec), myR, 0)).Value = Val(updval)
sagot = MsgBox("Record: " & "[" & addrec & "]" & _
" successfully added." & vbNewLine & _
"Do you want to add another Record?", vbYesNo, "AddNew")
If sagot = vbYes Then
GoTo Search
Else
Exit For
End If
End If
Next
End If
'Next
Application.ScreenUpdating = True
Application.EnableEvents = True
End With
End Function
 
Upvote 0
:beerchug:

yep...great yaar...Villy.
Thanks Dude.

Amazing
 
Last edited:
Upvote 0
You can also try this based on your requirement..change to suit.
Code:
Sub AddRec()
With Range("A9")
    If IsEmpty(Range("A9")) = False Then
    ans = MsgBox("Do you want to add new record?", vbYesNo, "AddNewRecord")
    If ans = vbYes Then
        For x = 9 To Range("A" & Rows.Count).End(xlUp).Row
            If Range("A" & x + 6) = Empty Then
                Range("A" & x + 6).Value = Range("A9")
                Exit Sub
            End If
        Next x
    Else
        Exit Sub
    End If
    End If
End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top