LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default VBA Macro help needed

I don't know this is what you want, but try this one.

copy and paste the following code to your Main sheet's module.
Click cells in column A or B or enter data in Main sheet. then, data in
Main sheet would be copied in sheet2 in this case.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim tmp As Range
Dim Destsh As Worksheet

Application.EnableEvents = False

'Data in Main sheet will be transfer to destsh
Set Destsh = Worksheets("Sheet2") 'Change to your sheet's name

On Error Resume Next
If Target.Value = "" Then
Application.EnableEvents = True
Exit Sub
End If

Set tmp = Destsh.Columns("A:B").Find(Target.Value, _
LookIn:=xlValues, lookat:=xlWhole)

On Error GoTo 0
If Not tmp Is Nothing Then
MsgBox Target.Value & ":already exist. Contact your branch manager"
Exit Sub
End If

Select Case Target.Column Mod 2

Case 0
Set tmp = Destsh.Cells(Cells.Rows.Count, "B").End(xlUp)
If tmp < "" Then
tmp.Offset(1, 0) = Target.Value
Else
tmp = Target.Value
End If

Case 1
Set tmp = Destsh.Cells(Cells.Rows.Count, "A").End(xlUp)
If tmp < "" Then
tmp.Offset(1, 0) = Target.Value
Else
tmp = Target.Value
End If

Case Else

End Select

Application.EnableEvents = True

End Sub

keiji


Vijay DSK wrote:
Yes ND Pard
You are right. But the thing is it should be done with the help of VBA and
the change is not time based. Hence what I am looking what ever new thing
appears in those cells, they should be copied and pasted in the other sheet.

And also if any duplicate entry appears it should give a messae box stating
that "Contact your branch manger".

Hope I am clear.

Harald:
I am looking for a excel sheet only, but not for the user forms.


"ND Pard" wrote:

Appears that all you need to do is a Copy followed by a Paste-Special |
Transpose

Good Luck.

"Vijay DSK" wrote:

Hi all,
Thanks once again for the help rendered by this forum.
Once again its time for me to ask an other question.

The question is
I have 2 excel sheets. In sheet1 (Name is Main), i have customer name in A1
and customer no in A2, B1 will carry the customer name and B2 will carry the
customer no.

What I am looking at is ........
Any entry punched in the cells (B1 & B2) should be copied on to sheet 2 of
A2 and B2. Like wise any value punched in those cells should be copied on to
A3 and B3 and so on....
An other point is the vba should give a message "Contact Branch Manager" if
any duplicate entry is added.

Hope I am clear in asking the question.

Thanks once again.



 
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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
MACRO NEEDED AshMorK Excel Discussion (Misc queries) 7 November 27th 06 05:47 PM
Macro needed to set macro security in Excel to minimum Carl Excel Programming 3 March 18th 06 03:36 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


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