Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default For Each with Select Case


ColumA ColumB

i have problem in this code, the integers in columB do not appea
correctly
i tried to use this code to first check if A1*.005 is between 0---.
then put
b.value =

Sub Tax4SalesTax()
Dim c As Range
Dim b As Range

For Each b In Range("B1:B5")
For Each c In Range("A1:A5")
Select Case c * 0.005
Case 0 To 0.5
b.Value = 0.5
Case 0.5 To 1
b.Value = 1
Case 1 To 1.5
b.Value = 1.5
Case 1.5 To 2
b.Value = 2
Case 2 To 2.5
b.Value = 2.5
Case 2.5 To 3
b.Value = 3
End Select
Next
Next
End Sub

i appreciate any hel

--
helmekk

-----------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...nfo&userid=693
View this thread: http://www.excelforum.com/showthread.php?threadid=26939

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default For Each with Select Case

So you're just checking the stuff in column A. if it meets a criterion, you
change the value in column B (of the same row)?

Sub Tax4SalesTax2()
Dim c As Range
For Each c In Range("A1:A5")
Select Case c * 0.005
Case 0 To 0.5: c.Offset(0, 1).Value = 0.5
Case Is <= 1: c.Offset(0, 1).Value = 1
Case Is <= 1.5: c.Offset(0, 1).Value = 1.5
Case Is <= 2: c.Offset(0, 1).Value = 2
Case Is <= 2.5: c.Offset(0, 1).Value = 2.5
Case Is <= 3: c.Offset(0, 1).Value = 3
End Select
Next c
End Sub

I'm not sure what you wanted to happen when c*.005 was equal to 1.

helmekki wrote:

ColumA ColumB

i have problem in this code, the integers in columB do not appear
correctly
i tried to use this code to first check if A1*.005 is between 0---.5
then put
b.value =

Sub Tax4SalesTax()
Dim c As Range
Dim b As Range

For Each b In Range("B1:B5")
For Each c In Range("A1:A5")
Select Case c * 0.005
Case 0 To 0.5
b.Value = 0.5
Case 0.5 To 1
b.Value = 1
Case 1 To 1.5
b.Value = 1.5
Case 1.5 To 2
b.Value = 2
Case 2 To 2.5
b.Value = 2.5
Case 2.5 To 3
b.Value = 3
End Select
Next
Next
End Sub

i appreciate any help

--
helmekki

------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=269390


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default For Each with Select Case

I would probably skip the VB code on this one and just use an Excel
CEILING formula. In column B
=Ceiling(A1,.5)
Then drag over the cells in column B you want this formula applied to.

helmekki wrote in message ...
ColumA ColumB

i have problem in this code, the integers in columB do not appear
correctly
i tried to use this code to first check if A1*.005 is between 0---.5
then put
b.value =

Sub Tax4SalesTax()
Dim c As Range
Dim b As Range

For Each b In Range("B1:B5")
For Each c In Range("A1:A5")
Select Case c * 0.005
Case 0 To 0.5
b.Value = 0.5
Case 0.5 To 1
b.Value = 1
Case 1 To 1.5
b.Value = 1.5
Case 1.5 To 2
b.Value = 2
Case 2 To 2.5
b.Value = 2.5
Case 2.5 To 3
b.Value = 3
End Select
Next
Next
End Sub

i appreciate any help

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
select case Hein Excel Discussion (Misc queries) 5 November 24th 09 01:19 PM
Case Select NoodNutt Excel Worksheet Functions 7 September 21st 08 02:10 AM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select Case Jeff Excel Discussion (Misc queries) 1 February 27th 06 02:56 PM
select case help please Christine Flott[_2_] Excel Programming 4 July 29th 03 09:05 PM


All times are GMT +1. The time now is 08:15 PM.

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"