RAJESH1960
Banned for repeated rules violations
- Joined
- Mar 26, 2020
- Messages
- 2,313
- Office Version
- 2019
- Platform
- Windows
Hello guys, I have these 2 working sheets. Except cell D1 on Sheet Gross and cell A1 in Sheet Extract, the sheet is protected and hidden. I select the date in cell A1 Sheet Extract with a formula, to get the month from Sheet Gross I want to work. When I run the code, the cells from A1 to AE1 are selected. I want the code to select only the cells which have date and not blank. I need your expert advice to change the code. The line of code I am using is Range("A1:AE1").Select
I want the code to select A1 till the end where the dates end. Different months have different number of days like 28, 29 , 30 and 31.
Due to the formula in cells AC1:AE1 it is selecting the whole row. I want it to select the cells which contain value and not blank. This is the full code...
Option Explicit
Sub RandomFigures()
Sheets("Extract").Select
'change range below here for days as per month
Range("A2:AE619").Select
Selection.FormulaR1C1 = "=RANDBETWEEN(10,90*10)*10"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'change range below here for days as per month
Range("A1:AE1").Select
Sheets("Gross").Select
Range("AJ5 ").Select
End Sub
I want the code to select A1 till the end where the dates end. Different months have different number of days like 28, 29 , 30 and 31.
Query Remove dates if not of that month.xlsx | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | AB | AC | AD | AE | ||||||||||||||||||||||||||||
1 | 01-02-2022 | 02-02-2022 | 28-02-2022 | ||||||||||||||||||||||||||||||
2 | |||||||||||||||||||||||||||||||||
3 | |||||||||||||||||||||||||||||||||
4 | |||||||||||||||||||||||||||||||||
Extract |
Cell Formulas | ||
---|---|---|
Range | Formula | |
A1 | A1 | =Gross!A14 |
B1,AB1 | B1 | =A1+1 |
AC1:AE1 | AC1 | =IF(AB1="","",IF(MONTH(AB1+1)=MONTH($A1),AB1+1,"")) |
Query Remove dates if not of that month.xlsx | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | 2021-22 | |||||
2 | ||||||
3 | Month | |||||
4 | Apr-21 | |||||
5 | May-21 | |||||
6 | Jun-21 | |||||
7 | Jul-21 | |||||
8 | Aug-21 | |||||
9 | Sep-21 | |||||
10 | Oct-21 | |||||
11 | Nov-21 | |||||
12 | Dec-21 | |||||
13 | Jan-22 | |||||
14 | Feb-22 | |||||
15 | Mar-22 | |||||
Gross |
Cell Formulas | ||
---|---|---|
Range | Formula | |
A4:A15 | A4 | =IF(DATE(LEFT($D$1,4),ROW(A4),1)<=DATE(LEFT($D$1,2)&RIGHT($D$1,2),ROW($A$3),1),DATE(LEFT($D$1,4),ROW(A4),1),"") |
Due to the formula in cells AC1:AE1 it is selecting the whole row. I want it to select the cells which contain value and not blank. This is the full code...
Option Explicit
Sub RandomFigures()
Sheets("Extract").Select
'change range below here for days as per month
Range("A2:AE619").Select
Selection.FormulaR1C1 = "=RANDBETWEEN(10,90*10)*10"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'change range below here for days as per month
Range("A1:AE1").Select
Sheets("Gross").Select
Range("AJ5 ").Select
End Sub
Last edited: