View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pignick pignick is offline
external usenet poster
 
Posts: 14
Default Help with syntax in line of code

I am trying to write a macro that will insert one of a number of possible
logos depending on the "user group" name, which appears in a cell after data
is downloaded to the worksheet.

The following code stops at the line UserGroup=Selection.String -
(highlighted yellow in the debug) - there is obviously something wrong with
the syntax here and I have tried a number of things without success. I know
it works in other situations where I use Dim CritValue as Integer and then do
IF, THEN statements to act on different numbers of CritValue, but as this is
text it doesn't work the same way. Can anyone help please?

Dim UserGroup As String
UserGroup = " "
ActiveSheet.Unprotect
ActiveSheet.Range("AJ1").Select
UserGroup = Selection.String
If UserGroup = "Garth Partnership" Then
(the subsequent instructions to insert the logo work fine from a macro
linked to an object but I want to automate this without the need for clicking
on an object).

Thanks in anticipation.
--
pignick