Hey guys, so I'm trying to write a macro that uses relative referencing based on the active cell selected. Currently I have what is written below. I'm trying to make it so it checks each cell all the way to the left in the corresponding A cell to see if it is bold. If it is bold then I want it to output an x in the range b:c. For some reason whenever I run this macro it is freezing up my excel which means (I think), it is trying to calculate WAAAYYY more than I'm meaning for it to. Any ideas?
I'm trying to make it so it checks each cell all the way to the left in the corresponding A cell to see if it is bold
Q1: Do you mean the cell in column A of the ActiveCell's row?
If it is bold then I want it to output an x in the range b:c.
Q2: Range B:C is a little over 2 million cells. Do you want an "X" in all 2M, or do you mean an "X" in column B and column of the row that the active cell is in?
For some reason whenever I run this macro it is freezing up my excel which means (I think), it is trying to calculate WAAAYYY more than I'm meaning for it to.
Q3: I'll be it is. You're checking 2 million x 82 cells = 164,000,000 cells. That's a lot
Any ideas?
Q4: Yes. Tell us what you want to do, and not how you think you need to do it
Q5:
a. No need to select the ActiveCell
b. No need to set it to b unless you want to return to it
c. c is 83 ROWS after the ActiveCell, same COLUMN. Where did the 83 come from?
d. I think your loops are wrong
e. You said you wanted to use relative addressing of ActiveCell, but your macro does not use ActiveCell (sets it but never uses it)
f. You loop A2:A83 for some reason
f. You set c but never use it
Option Explicit
Sub xmarksthespot()
Dim a As Range, b As Object, c As Object, cells As Object, cells2 As Object
ActiveCell.Select
Set b = ActiveCell
Set c = ActiveCell.Offset(83, 0)
For Each cells In Range("b:c")
For Each cells2 In Range("A2:A83")
If cells2.Font.Bold = True Then
cells = "x"
End If
Next
Next
End Sub
I think there might be a terminology disconnect, so I'm guessing that you were looking for something like these, which might get you started.
Else I/we will need more information
Option Explicit
Sub xmarksthespot_guess()
With ActiveCell.EntireRow
If .cells(1).Font.Bold Then
.cells(2).Value = "X"
.cells(3).Value = "X"
End If
End With
End Sub
Sub xmarksthespot_guess_2()
Dim C As Range
For Each C In Range("A2:A83").cells
With C
If .Font.Bold Then
.Offset(0, 1).Value = "X"
.Offset(0, 2).Value = "X"
End If
End With
Next
End Sub
Sub xmarksthespot_guess_3()
Dim C As Range
For Each C In Selection.cells
With C.EntireRow
If .cells(1).Font.Bold Then
.cells(2).Value = "X"
.cells(3).Value = "X"
End If
End With
Next
End Sub