Range.currentregion and offsetting a case to range count

Whaletacos

New Member
Joined
Aug 10, 2017
Messages
13
Hi everybody.

I've been tinkering with a small code section using the Currentregion and trying to offset a case based on it

What I was hoping for, was a currentregion.rows.count = x, lets say 10.
Then for each of those 10 rows, it would apply the cases below on offset(0,12) and (0,13).


I hope anybody is able to help a vba novice. I'm sure it is something rather simple I am missing out on.

Kind regards
WhaleTacos

Code:
Sub cases()


Dim rngCell As Range
Dim rngStart As Range
Dim lngRows As Long




Set rngStart = Range("B2").CurrentRegion
lngRows = rngStart.CurrentRegion.Rows.Count




    For Each rngCell In rngStart
        With rngCell.Offset(0, 0)
            Select Case rngCell.Value
                
                Case Is = "5Cal540"
                    .Value = "5CalF"
                
                Case Is = "Qua705"
                    .Value = "Quasar 705"
                   
            End Select
        End With
    Next rngCell
    


End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Well I came up with the following solution. It isnt pretty though.


Code:
Sub cases()


Dim rngCell As Range
Dim rngStart As Range






Set rngStart = Range("B2").CurrentRegion




    For Each rngCell In rngStart.Offset(0, 11)
        With rngCell.Offset(0, 0)
            Select Case rngCell.Value
                
                Case Is = "5Cal540"
                    .Value = "5CalF"
                
                Case Is = "56-FAM"
                    .Value = "Quasar 705"
                   
            End Select
        End With
    Next rngCell
    


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top