Need help using VBA in excel.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following is some VBA code being run using a Macro.

ActiveCell.Select
Selection.Interior.ColorIndex = 34
Range("G4").FormulaR1C1 = "=countbycolor(Belmarsh,34,FALSE)"
End Sub

"Belmarsh" is a cell range. Is there any way of inputting a cell specific
cell range i.e. E11:B12 or $E$11:$B$12 in VBA. Whenever I try this it errors.
Any ideas??

Thanks

Chris
 
Range("G4").Formula = "=countbycolor(E11:B12,34,FALSE)"

should work. Notice since the formula is in A1 notation, i use Formula
rather than FormulaR1C1
 
Hi
with activesheet.range("B11:E12")
..Interior.ColorIndex = 34
end with
 
try
ActiveCell.Interior.ColorIndex = 34
Range("G4").Formula= "=countbycolor(range("e11:b12"),34,FALSE)"
 
wrong
Range("G4").Formula= "=countbycolor(range("e11:b12"),34,FALSE)"

right
Range("G4").Formula= "=countbycolor(e11:b12,34,FALSE)"
 
Maybe you mean something like

Range("G4").Formula= "=countbycolor(" & _
range("e11:b12").Address & ",34,FALSE)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top