If statement to change value of next empty cell in range on another sheet

jchi2210

New Member
Joined
Apr 12, 2021
Messages
8
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
Hello guys, I'm trying to wrap my head around this and it's driving me nuts.

I'm trying to setup an If statement so that if it's true, then it places text on a specific range on another sheet on the next empty cell in that range. I tried it with ranges and couldn't figure it out so just to get it working I tried working with just a specific row starting at a specific point and I seem to have broken that as well.

The Range to copy to on Templates is B12:G22. It's currently only changing the value of B12 in the "Template" sheet, which is great that I got that working. But I want to be able to hit the button again and it move to B13. If B13 has a value of any kind in it, then move on. After filling up B22, I was trying to get it to move to C12 and continue on. I know this is kind of over my head and I apologize.

If Sheets("Main").Range("Y4").Value = 2 Then
Sheets("Template").Range("B12").Value = 1
With Sheets("Template").Range("B" & Rows.Count).End(xlUp).Offset(12)
End With
End If
 

jchi2210

New Member
Joined
Apr 12, 2021
Messages
8
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
So are you just after this:

VBA Code:
Option Explicit
Sub Macro2()

    Application.ScreenUpdating = False

    If Sheets("Main").Range("Y4").Value = 2 Then
        Sheets("Template").Range("B12:G22").Value = 1
    End If
   
    Application.ScreenUpdating = True

End Sub

Just change the range in second line to suit (the range could even be in a cell that is referenced).
Just what I need. Thank you!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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,151,962
Messages
5,767,350
Members
425,405
Latest member
jaskimo

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