Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default IF STATMENT OR CASE STATEMENT

OS: MS XP
EXCEL: 2000

I have a Marco, which I use to print a selection from a sheet.

I want to use this macro to make the selection. I use a spinner to select
the date. The spinner puts a number in the cell D4. I need to somehow
convert this number into the selection.

Im not very familiar with the IF statement or the CASE statement. Do I use
a FUNCTION and if I do how do I pass he variable D4?

Exampl:
Number in cell D4 = 4.
Selection needed = Columns("H:H").Select

My Macro.

Application.ScreenUpdating = False
Sheets("Print").Visible = True
Sheets("KC").Select
Cells.Select
Selection.Copy
Sheets("Print").Select
Cells.Select
ActiveSheet.Paste
Cells.Select
Selection.Font.ColorIndex = 0
Selection.Interior.ColorIndex = xlNone
Range("H14").Select
ActiveCell.FormulaR1C1 = "=NOW()+1"
Columns("H:H").Select
Selection.PrintOut Copies:=1, Collate:=True
Cells.Select
Selection.ClearContents
Range("A4").Select
ActiveWindow.SelectedSheets.Visible = False
Application.ScreenUpdating = False
Range("A62").Select

Please hepp.

Thanks in advance.

--
Richard
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default IF STATMENT OR CASE STATEMENT

You have:

Columns("H:H").Select

How about:

cls = Range("D4").Value
Columns(cls).Select


--
Gary's Student


"Richard" wrote:

OS: MS XP
EXCEL: 2000

I have a Marco, which I use to print a selection from a sheet.

I want to use this macro to make the selection. I use a spinner to select
the date. The spinner puts a number in the cell D4. I need to somehow
convert this number into the selection.

Im not very familiar with the IF statement or the CASE statement. Do I use
a FUNCTION and if I do how do I pass he variable D4?

Exampl:
Number in cell D4 = 4.
Selection needed = Columns("H:H").Select

My Macro.

Application.ScreenUpdating = False
Sheets("Print").Visible = True
Sheets("KC").Select
Cells.Select
Selection.Copy
Sheets("Print").Select
Cells.Select
ActiveSheet.Paste
Cells.Select
Selection.Font.ColorIndex = 0
Selection.Interior.ColorIndex = xlNone
Range("H14").Select
ActiveCell.FormulaR1C1 = "=NOW()+1"
Columns("H:H").Select
Selection.PrintOut Copies:=1, Collate:=True
Cells.Select
Selection.ClearContents
Range("A4").Select
ActiveWindow.SelectedSheets.Visible = False
Application.ScreenUpdating = False
Range("A62").Select

Please hepp.

Thanks in advance.

--
Richard

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default IF STATMENT OR CASE STATEMENT

Maybe something like

Application.ScreenUpdating = False
Sheets("Print").Visible = True
With Sheets("Print")
Sheets("KC").Cells.Copy .Range("A1")
.Cells.Font.ColorIndex = 0
.Cells.Interior.ColorIndex = xlNone
.Range("H14").FormulaR1C1 = "=NOW()+1"
Select Case .Range("D4").Value
Case 4
.Columns("H:H").PrintOut Copies:=1, Collate:=True
Case 4
.Columns("M:M").PrintOut Copies:=1, Collate:=True
'etc
End Select
.Cells.ClearContents
End With
ActiveWindow.SelectedSheets.Visible = False
Application.ScreenUpdating = False
Range("A62").Select


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Richard" wrote in message
...
OS: MS XP
EXCEL: 2000

I have a Marco, which I use to print a selection from a sheet.

I want to use this macro to make the selection. I use a spinner to select
the date. The spinner puts a number in the cell D4. I need to somehow
convert this number into the selection.

I'm not very familiar with the IF statement or the CASE statement. Do I

use
a FUNCTION and if I do how do I pass he variable D4?

Exampl:
Number in cell D4 = 4.
Selection needed = Columns("H:H").Select

My Macro.

Application.ScreenUpdating = False
Sheets("Print").Visible = True
Sheets("KC").Select
Cells.Select
Selection.Copy
Sheets("Print").Select
Cells.Select
ActiveSheet.Paste
Cells.Select
Selection.Font.ColorIndex = 0
Selection.Interior.ColorIndex = xlNone
Range("H14").Select
ActiveCell.FormulaR1C1 = "=NOW()+1"
Columns("H:H").Select
Selection.PrintOut Copies:=1, Collate:=True
Cells.Select
Selection.ClearContents
Range("A4").Select
ActiveWindow.SelectedSheets.Visible = False
Application.ScreenUpdating = False
Range("A62").Select

Please hepp.

Thanks in advance.

--
Richard



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
Trying to select a specific range based on the time value of user form input Jitranijam New Users to Excel 8 November 15th 06 12:52 AM
VBA Code Cell Mate Excel Discussion (Misc queries) 4 January 9th 06 08:52 PM
Loop for VBA code? paulinoluciano Excel Worksheet Functions 5 December 28th 05 01:30 PM
convert value in word. For Exampe Rs.115.00 convert into word as . Shakti Excel Discussion (Misc queries) 1 May 10th 05 12:00 PM
Identifying the Active Fill Color Steve Conary Excel Discussion (Misc queries) 3 December 9th 04 04:45 AM


All times are GMT +1. The time now is 11:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"