Crazyjokerz
New Member
- Joined
- Feb 23, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi, i'm new with VBA, learning by myself, and i didn't found my answer. I know other language like Python, C for example.
Here is my work :
function ClearCells() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Daily');
sheet.getRange('B3:B5').clearContent();
sheet.getRange('D3:D5').clearContent();
sheet.getRange('B9:B16').clearContent();
sheet.getRange('D9:D16').clearContent();
sheet.getRange('F9:F16').clearContent();
sheet.getRange('H9:H16').clearContent();
sheet.getRange('J9:J16').clearContent();
sheet.getRange('L9:L16').clearContent();
sheet.getRange('N9:N16').clearContent();
sheet.getRange('P9:P16').clearContent();
}
It's quite basic & stupid. I would like to get a loop "for" or "while". like :
for (i going to B to P, i + 2), so that the variable 'i' take the value of B, then D, then F ... until P
and also that my cells ("B3:B5") looks more like ''i''X':'i''X+range')
My problem is that when i add lines before, the code is not following and i have to change it in every line of code.
As i said, i'm new and i basicly know nothing, i'm not asking for explanations, i can dig on internet to understand, but a code quite easy to understand would help me.
Sorry if my english is approximate, i'm doing my best here too
Thanks if you took the time to read me
Here is my work :
function ClearCells() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Daily');
sheet.getRange('B3:B5').clearContent();
sheet.getRange('D3:D5').clearContent();
sheet.getRange('B9:B16').clearContent();
sheet.getRange('D9:D16').clearContent();
sheet.getRange('F9:F16').clearContent();
sheet.getRange('H9:H16').clearContent();
sheet.getRange('J9:J16').clearContent();
sheet.getRange('L9:L16').clearContent();
sheet.getRange('N9:N16').clearContent();
sheet.getRange('P9:P16').clearContent();
}
It's quite basic & stupid. I would like to get a loop "for" or "while". like :
for (i going to B to P, i + 2), so that the variable 'i' take the value of B, then D, then F ... until P
and also that my cells ("B3:B5") looks more like ''i''X':'i''X+range')
My problem is that when i add lines before, the code is not following and i have to change it in every line of code.
As i said, i'm new and i basicly know nothing, i'm not asking for explanations, i can dig on internet to understand, but a code quite easy to understand would help me.
Sorry if my english is approximate, i'm doing my best here too

Thanks if you took the time to read me