How to make a Case Function.

  • Thread starter Thread starter arcq
  • Start date Start date
A

arcq

Hi people of great minds.

i'm working on some codes and i need your help.

the thing is i have a table where in each row the value is sorted
according to its Item No. however, the data has to be grouped
according to its kind and printed together with a drawing that
represents such data. so i made a macro for each kind and sorted the
data first before transferring them into another sheet.

the problem is..... 1. the file size is extremely big.
2. after printing, i have to sort it out manually.

so if anybody can at least explain how to start with select case
funtion..... what variables to declare, where to take reference
from......and such..... it would be a great help.

i tried to search and found some samples, however, i can not understand
fully since most of these samples that are posted here, does not start
from the very top. mostly, they are just showing what the
errors/corrections that has to be made.

by the way, i'm new at this VB thing. and i'm very interested.

thank you very much.
 
Hi, arcq,

Here's a nice simple case statement to start you off.
It displayd a dialog box and does different things according to the value
you enter into it.

Sub CaseStatement()
Dim WhatToDo As String

WhatToDo = InputBox("Prompt Text", "DialogBoxTitle", "Default Displayed
Value")
Select Case WhatToTo
Case 1: MsgBox ("1") 'or enter code here or the name of another
macro to run
Case 2: MsgBox ("2") 'or enter code here or the name of another
macro to run
Case 3: MsgBox ("3") 'or enter code here or the name of another
macro to run
End Select
End Sub

Select Case is based on the value of WhatToDo, which is what is returned
from the dialog box when you enter a value (in this case, 1, 2 or 3) and
click OK
I know you don't necessarily need a dialog box for your requirements, but if
you're interested in VBA, it a good prompt to be able to get info from the
user.

Hope this helps

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top