Macros, first free cell to be with black text

K0st4din

Well-known Member
Joined
Feb 8, 2012
Messages
501
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hello, everyone,
please for your help, for a macro that i do not know how to do.
I have 15 worksheets with specific names (peaches, tomatoes, apples, etc.).
In each of them all cells are made - the text in them is red. But in each worksheet, the length of the rows is different: for example: in "Apples" - is up to 564 lines, in Peaches - is up to 125, Tomatoes - is up to 1250.
I'm looking for a way, with a macro, after pressing the macro button, each free next line, more precisely a cell in column B:B, to write - "FINISH" and be black in the text.
From the example given: In "Apples" - cell B565, "Peaches" - cell B126, in "tomatoes" - cell B1251

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]sheet Apples[/TD]
[TD]sheet Peaches[/TD]
[TD]sheet tomatoes[/TD]
[/TR]
[TR]
[TD]text[/TD]
[TD]text[/TD]
[TD]text[/TD]
[/TR]
[TR]
[TD]text[/TD]
[TD]text[/TD]
[TD]text[/TD]
[/TR]
[TR]
[TD]text[/TD]
[TD]text[/TD]
[TD]text[/TD]
[/TR]
[TR]
[TD]text[/TD]
[TD]text[/TD]
[TD]FINISH[/TD]
[/TR]
[TR]
[TD]text[/TD]
[TD]text[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]text[/TD]
[TD]text[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]FINISH[/TD]
[TD]text[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]text[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD]text[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]FINISH[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Thank you all in advance!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Maybe this

Code:
Sub MM1()
Dim ws As Worksheet, lr As Long
For Each ws In Worksheets
    lr = ws.Cells(Rows.Count, "B").End(xlUp).Row
        ws.Range("B" & lr + 1).Value = "FINISH"
Next ws
End Sub
 
Upvote 0
Hello,
I'll try it out right away, but I do not understand a lot of macros, but I do not see the text anywhere black. Since the tables are locked and all the rows are made to write in red text, I need this final to be in black text (see my table example).
The second, which I would like to ask, to make reference to which worksheets I put this condition.
I mean:
Array(Peaches, Apple, ect.)
 
Upvote 0
If you put it in a Standard module it will work on ALL sheets in the workbook.
Try it and see if ALL text returns in red.... if so I will modify it
 
Upvote 0
Hello,
since the worksheets are made to write in red and then locked, my text goes back to red. In this workbook I have other worksheets and for this reason I would like to say in which one the macro works Array(sheets.name...........)
 
Upvote 0
.. the worksheets are made to write in red and then locked, .... I would like to say in which one the macro works Array(sheets.name...........)
By "locked" I assume you mean "Protected"?
If so, do all the sheets you want to work on have the same password to Unprotect?
 
Upvote 0
By "locked" I assume you mean "Protected"?
- Yes, Protected

If so, do all the sheets you want to work on have the same password to Unprotect? -

- These specific worksheets are made so that they can be written in them, but they can not change, nothing in them.

The macro will be used in 100% Unprotected sheets.
Figuratively speaking, I have a lot of worksheets in my chosen information and the distribution is the same.
In order not to do it by hand for each worksheet, I search for your help, the macro does it and in column B2:B first free cell to put the word "FINISH" and make the text black.

In my first comment I tried to show it.
You do not give us an option to attach a file.


Thank you in advance.
 
Upvote 0
You can upload files to viewing sites like dropbox, but not directly to this forum.
You said initially that there were 15 sheets affected, so I assumed ( wrongly) that it affected ALL sheets in the workbook.
So, how many sheets are there in the workbook, and how many are affected by this macro ?

Code:
Sub MM1()
Dim ws As Worksheet, lr As Long
For Each ws In Worksheets
    lr = ws.Cells(Rows.Count, "B").End(xlUp).Row
        ws.Range("B" & lr + 1).Value = "FINISH"
        ws.Range("B" & lr + 1).Font.Color = vbblack
Next ws
End Sub
 
Last edited:
Upvote 0
The macro will be used in 100% Unprotected sheets.
OK, I was confused by you using the term "locked".
Try this with a copy of your workbook.

Rich (BB code):
Sub Finished()
  Dim wSheets As Variant, Sh As Variant
  
  wSheets = Array("Peaches", "Apples")  '<- Add more if you want
  For Each Sh In wSheets
    With Sheets(Sh).Columns("B").Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious).Offset(1)
      .Value = "FINISHED"
      .Font.Color = vbBlack
    End With
  Next Sh
End Sub


You do not give us an option to attach a file.
That is correct. My signature block below has a link with suggestions for how you can post small screen shots.
 
Upvote 0
Yes, yes, yes that's what I was looking for as a macro.
Thank you very much.
Again and again you helped me to help my job go faster.
You are all unique Peter_SSs and Michael M.
I wish you good health.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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
Back
Top