Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Data Modification


Hi Dears

I have following codes to Enter New data into Sheet.

Private Sub CommandButton1_Click()
Dim irow As Long
Dim ws As Worksheet
Dim rng As Range
Dim res As Variant

Set ws = Worksheets("CIssue")

With ws
Set rng = .Range(.Range("a2"), .Range("a2").End(xlDown))
End With

res = Application.Match(CLng(CDate(Me.TextBox1.Value)), rng, 0)

If IsError(res) Then

irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

ws.Cells(irow, 1).Value = Me.TextBox1.Value
ws.Cells(irow, 2).Value = Me.TextBox2.Value
ws.Cells(irow, 3).Value = Me.TextBox3.Value
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.TextBox1.SetFocus
Else
MsgBox "Data Already Exist", vbCritical
TextBox2 = Sheet8.Range("a1").Offset(res, 1).Value
TextBox3 = Sheet8.Range("a1").Offset(res, 2).Value
End If
Me.TextBox1.SetFocus

End Sub

I would like to ask the codes for modification of data. Suppose when i
put the required code in textbox1.

1. It search the data
2. if found then retrive the data in Textbox2 and textbox3
3. Put the replaced data in the existing row.

Thanks,

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=533191

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Data Modification

Private Sub CommandButton1_Click()
Dim irow As Long
Dim ws As Worksheet
Dim rng As Range
Dim res As Variant

Set ws = Worksheets("CIssue")

With ws
Set rng = .Range(.Range("a2"), .Range("a2").End(xlDown))
End With

res = Application.Match(CLng(CDate(Me.TextBox1.Value)), rng, 0)

If IsError(res) Then

irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

ws.Cells(irow, 1).Value = Me.TextBox1.Value
ws.Cells(irow, 2).Value = Me.TextBox2.Value
ws.Cells(irow, 3).Value = Me.TextBox3.Value
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.TextBox1.SetFocus
Else
ans = MsgBox( "Data Already Exist, Update?", vbCritical+vbYesNo)
if ans = vbYes then
set rng1 = rng(res)
rng1.offset(0,1).Value = TextBox2
rng1.offset(0,2).Value = Textbox3
End If
End If
Me.TextBox1.SetFocus

End Sub

I would like to ask the codes for modification of data. Suppose when i
put the required code in textbox1.


--
Regards,
Tom Ogilvy


"Syed Haider Ali"
<Syed.Haider.Ali.26bnqm_1145131801.7331@excelfor um-nospam.com wrote in
message news:Syed.Haider.Ali.26bnqm_1145131801.7331@excelf orum-nospam.com...

Hi Dears

I have following codes to Enter New data into Sheet.

Private Sub CommandButton1_Click()
Dim irow As Long
Dim ws As Worksheet
Dim rng As Range
Dim res As Variant

Set ws = Worksheets("CIssue")

With ws
Set rng = .Range(.Range("a2"), .Range("a2").End(xlDown))
End With

res = Application.Match(CLng(CDate(Me.TextBox1.Value)), rng, 0)

If IsError(res) Then

irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

ws.Cells(irow, 1).Value = Me.TextBox1.Value
ws.Cells(irow, 2).Value = Me.TextBox2.Value
ws.Cells(irow, 3).Value = Me.TextBox3.Value
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.TextBox1.SetFocus
Else
MsgBox "Data Already Exist", vbCritical
TextBox2 = Sheet8.Range("a1").Offset(res, 1).Value
TextBox3 = Sheet8.Range("a1").Offset(res, 2).Value
End If
Me.TextBox1.SetFocus

End Sub

I would like to ask the codes for modification of data. Suppose when i
put the required code in textbox1.

1. It search the data
2. if found then retrive the data in Textbox2 and textbox3
3. Put the replaced data in the existing row.

Thanks,

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile:

http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=533191



Reply
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
Code modification help AndyMP Excel Worksheet Functions 1 February 8th 09 11:41 PM
last modification Chip Smith Excel Discussion (Misc queries) 1 June 19th 06 11:55 PM
Lock to copy/ modification data ilyaskazi[_86_] Excel Programming 2 October 14th 05 08:42 AM
modification for the code srinivasan Excel Programming 2 August 20th 05 03:12 PM
Modification Steved[_3_] Excel Programming 2 September 8th 04 08:09 PM


All times are GMT +1. The time now is 01:15 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"