Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Help with syntax in line of code

UserGroup = Selection.Value
--
Gary''s Student - gsnu200796
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
Combined VBA line syntax Neal Zimm Excel Programming 5 May 4th 05 10:46 PM
VBE syntax line question Colette Excel Programming 3 November 16th 03 07:34 PM
More on VBE syntax line question Colette Excel Programming 4 November 16th 03 05:39 PM
VBA Row(line) No Syntax? Michael168[_44_] Excel Programming 1 November 1st 03 05:36 AM


All times are GMT +1. The time now is 09:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"