LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Bringing up a message box if values already in cells - Help!!!!

Thanks Tom,

Worked superbly, absolutely brilliant.

Regards

Tom Ogilvy wrote:
If Range("D8").Value = ComboBox1 And Range("D9").Value = "" Then
Worksheets("Sheet1").Select
Range("E20:E31").Select
Selection.Copy
Worksheets("Sheet2").Select
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
ElseIf Range("D8").Value = ComboBox1 then
If Msgbox("Values already exist for this month do you want to
Overwrite?", vbOKCancel) = vbCancel Then
Exit Sub
Else
Worksheets("Sheet1").Select
Range("E20:E31").Select
Selection.Copy
Worksheets("Sheet2").Select
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
End If
End If


--
Regards,
Tom Ogilvy


" wrote:

This may be a tricky one to explain but I'll have a go.

As I understand it you cannot use Lookups in VBA?

I have a excel workbook and on sheet 1 I have some figures, then on
sheet 2 I have a summary sheet for the year, set out like so:

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

On sheet 1 I have a Macro called "Transfer figures to Summary" when
pressed a User form appears with a Combox containing all twelve months
of the year depending on which month you click the figures then appear
on sheet 2 under the correct month heading on the summary.

What I now want to put in is a msgbox containing the Message "This
Month Already contains values do you want to Overwrite?" if the user
selects OK then the Macro continues and if the user hits cancel then it
exits the sub, even this I have managed to do

But here is where I'm stuck because I don't think you can use look ups
in VBA and if you can I'm not to sure how too. I have put the VBA code
in 12 times pointing to each cell ref on the summary sheet so when you
run the macro each time the msgbox comes up all the time not just for
the particular month the combobox has selected.

Example:

(D8 = Jan, I have then copied this another 11 times for each month of
the year and changing the ref i.e. E8 = Feb, F8=Mar, G8=Apr etc etc)

Worksheets("Sheet2").Select

If Range("D8").Value = ComboBox1 And Range("D9").Value = "" Then
Worksheets("Sheet1").Select
Range("E20:E31").Select
Selection.Copy
Worksheets("Sheet2").Select
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
ElseIf Msgbox("Values already exist for this month do you want to
Overwrite?", vbOKCancel) = vbCancel Then
Exit Sub
Else
Worksheets("Sheet1").Select
Range("E20:E31").Select
Selection.Copy
Worksheets("Sheet2").Select
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
End If

End If

I'm sure this is a very long way round but I'm new to VBA and really
have hit a brick wall any help would be much appreciated



 
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
Locating values in a range and bringing up the corresponding price Zuo Excel Worksheet Functions 3 February 22nd 10 07:53 PM
restricted values error message Recordhop Excel Discussion (Misc queries) 2 May 25th 09 01:29 AM
cells without values causing error message karen Excel Discussion (Misc queries) 6 January 11th 08 06:39 PM
Displaying multiple values in a message box Dani Excel Programming 1 January 10th 06 09:43 PM
Input values directly in message box? JJ Excel Programming 2 January 13th 05 05:54 PM


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