-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
Dropbox adds Microsoft 365 real time co-authoring support in beta
By John Callaham,
- 0 replies
- 2 views
-
Microsoft 365 Roadmap Weekly: Designer is coming to Word and more
By John Callaham,
- microsoft
- microsoft 365
- (and 7 more)
- 0 replies
- 4 views
-
Microsoft 365 Roadmap Weekly: New Copilot features are coming to Word, Excel and more
By John Callaham,
- microsoft
- microsoft 365
- (and 5 more)
- 1 reply
- 4 views
-
Microsoft Excel on the web users can now share links to existing or new Sheet views
By John Callaham,
- 1 reply
- 2 views
-
Microsoft 365 Insiders can preview Check Performance in the Excel Windows app
By John Callaham,
- microsoft
- microsoft 365
- (and 3 more)
- 1 reply
- 1 view
-
Question
The Teej
Hi guys.
I'm working on a spreadsheet for work and using VBA to generate data (as well as theme the data cells) but I'm noticing I'm running into a lot of copypasta over redundant commands which in my programming experience should actually be done in a for loop - for example, the following segment of code:
Now, the code works, but it looks a bit messy. As you can see, the majority of this code in this segment is pretty much repeated - and it's not the only part of the code where this is taking place - and it's making small ammendments to the code quite a time consuming process - simply because of all of the copy and pasting that's going on. So in the spirit of time saving and cleaner code, is there a way I can cycle through columns in a for loop? I'm aware of how to do it for rows, as long as it's in the same column - but seen as columns are not numerical, I wasn't sure how to apply the same process for columns.
I'm pretty new to VBA, and haven't dabbled in VB in nearly 10 years, so I'm pretty rusty! Any help would be appreciated. Thanks :)
Link to comment
Share on other sites
7 answers to this question
Recommended Posts