OFFSET one row and one column if active cell is in specific column

Sufiyan97

Well-known Member
Joined
Apr 12, 2019
Messages
639
Office Version
  1. 2013
Platform
  1. Windows
I am using below code to enter time

I want to make it, offset one column if active cell is in column G
and OFFSET one row and one column if active cell is in column H

VBA Code:
Sub iTime()
    With ActiveCell
        .Value = Format(Time, "hh:mm")
         .Offset(0, 1).Select
   End With
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,339
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Sub iTime()
    With ActiveCell
        .Value = Format(Time, "hh:mm")
         If .Column = 7 Then
            .Offset(0, 1).Select
         Else
            .Offset(1, 1).Select
         End If
   End With
End Sub
 
Solution

Sufiyan97

Well-known Member
Joined
Apr 12, 2019
Messages
639
Office Version
  1. 2013
Platform
  1. Windows
Thank you very much Fluff

Works Perfect
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
68,339
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,568
Messages
5,770,900
Members
425,651
Latest member
Mark Cashin

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
Top