#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 542
Default Macro Help

I have a set a data that comes to me about 3 or 4 times a week. The data
looks like this
A B C ----Columns
12 1001 0
35 2.5
28 5.8
30 8
29 1035 0
56 3
42 6.2
22 2021 0
11 2.2
60 9.2

I am just concerned with column B and column C. A new sample ID starts
every time when there is a 0 in column C. I need something that will
increase the number in column B by 1. So for the first set I would want
column B to go from 1001, 1002, 1003, 1004. But when we hit the new sample ID
1035, I need the numbers to go 1035, 1036 etc... Below is what I would like
it to end up as:

A B C ----Columns
12 1001 0
35 1002 2.5
28 1003 5.8
30 1004 8
29 1035 0
56 1036 3
42 1037 6.2
22 2021 0
11 2022 2.2
60 2023 9.2

Thanks for any help.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 292
Default Macro Help

Sub test()
Dim D As Double
Dim R As Long
For R = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Val(Cells(R, 2).Value) 0 Then
D = Val(Cells(R, 2).Value)
Else
D = D + 1
Cells(R, 2).Value = D
End If
Next
End Sub

HTH. Best wishes Harald

"James" skrev i melding
...
I have a set a data that comes to me about 3 or 4 times a week. The data
looks like this
A B C ----Columns
12 1001 0
35 2.5
28 5.8
30 8
29 1035 0
56 3
42 6.2
22 2021 0
11 2.2
60 9.2

I am just concerned with column B and column C. A new sample ID starts
every time when there is a 0 in column C. I need something that will
increase the number in column B by 1. So for the first set I would want
column B to go from 1001, 1002, 1003, 1004. But when we hit the new sample
ID
1035, I need the numbers to go 1035, 1036 etc... Below is what I would
like
it to end up as:

A B C ----Columns
12 1001 0
35 1002 2.5
28 1003 5.8
30 1004 8
29 1035 0
56 1036 3
42 1037 6.2
22 2021 0
11 2022 2.2
60 2023 9.2

Thanks for any help.



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 542
Default Macro Help

It WORKS!!!! Thank you for answering me so quickly this will definately help
my workflows.

"Harald Staff" wrote:

Sub test()
Dim D As Double
Dim R As Long
For R = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Val(Cells(R, 2).Value) 0 Then
D = Val(Cells(R, 2).Value)
Else
D = D + 1
Cells(R, 2).Value = D
End If
Next
End Sub

HTH. Best wishes Harald

"James" skrev i melding
...
I have a set a data that comes to me about 3 or 4 times a week. The data
looks like this
A B C ----Columns
12 1001 0
35 2.5
28 5.8
30 8
29 1035 0
56 3
42 6.2
22 2021 0
11 2.2
60 9.2

I am just concerned with column B and column C. A new sample ID starts
every time when there is a 0 in column C. I need something that will
increase the number in column B by 1. So for the first set I would want
column B to go from 1001, 1002, 1003, 1004. But when we hit the new sample
ID
1035, I need the numbers to go 1035, 1036 etc... Below is what I would
like
it to end up as:

A B C ----Columns
12 1001 0
35 1002 2.5
28 1003 5.8
30 1004 8
29 1035 0
56 1036 3
42 1037 6.2
22 2021 0
11 2022 2.2
60 2023 9.2

Thanks for any help.




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 292
Default Macro Help

You're welcome. Really appreciate the feedback.

Best wishes Harald

"James" skrev i melding
...
It WORKS!!!! Thank you for answering me so quickly this will definately
help
my workflows.

"Harald Staff" wrote:

Sub test()
Dim D As Double
Dim R As Long
For R = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Val(Cells(R, 2).Value) 0 Then
D = Val(Cells(R, 2).Value)
Else
D = D + 1
Cells(R, 2).Value = D
End If
Next
End Sub

HTH. Best wishes Harald

"James" skrev i melding
...
I have a set a data that comes to me about 3 or 4 times a week. The
data
looks like this
A B C ----Columns
12 1001 0
35 2.5
28 5.8
30 8
29 1035 0
56 3
42 6.2
22 2021 0
11 2.2
60 9.2

I am just concerned with column B and column C. A new sample ID starts
every time when there is a 0 in column C. I need something that will
increase the number in column B by 1. So for the first set I would
want
column B to go from 1001, 1002, 1003, 1004. But when we hit the new
sample
ID
1035, I need the numbers to go 1035, 1036 etc... Below is what I would
like
it to end up as:

A B C ----Columns
12 1001 0
35 1002 2.5
28 1003 5.8
30 1004 8
29 1035 0
56 1036 3
42 1037 6.2
22 2021 0
11 2022 2.2
60 2023 9.2

Thanks for 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
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 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 03:41 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"