Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with syntax in line of code
UserGroup = Selection.Value
-- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "pignick" wrote in message ... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with syntax in line of code
UserGroup = Selection.Value
-- Gary''s Student - gsnu200796 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with syntax in line of code
Thanks, but I should have explained that I had initially tried that and it
doesn't work with the text string , which puzzled me as it does work in other situations using a number, so must be something wrong somewhere. Any other suggestions? -- pignick "Bob Phillips" wrote: UserGroup = Selection.Value -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "pignick" wrote in message ... 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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with syntax in line of code
Sorted it - the UserGroup name appeared to be referenced to cell AJ1 but that
cell was also merged with the next two cells - as soon as I unmerged them (which did not affect the display of the name as it simply spread across the adjacent cells anyway), the Selection.Value code worked fine and the rest of the macro was implemented. Thanks for your help - I'm slowly learning how to use VBA but it's frustrating when you come up against simple problems like this. -- pignick "pignick" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro code to put series name next to individual line in line grap | Charts and Charting in Excel | |||
Combined VBA line syntax | Excel Programming | |||
VBE syntax line question | Excel Programming | |||
More on VBE syntax line question | Excel Programming | |||
VBA Row(line) No Syntax? | Excel Programming |