?
Solved

Convert cell value to cell comment

Posted on 2015-01-09
3
Medium Priority
?
165 Views
Last Modified: 2015-01-09
Hello,

i need help with VBA,

on selection of a range, i want to run a macro that moves each cell value to cell comment and erases the cells and puts 1 in each of those cells.

thanks.
0
Comment
Question by:Flora
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 40539899
Hi,

pls try

Sub macro1()

For Each c In Selection
    Set cmt = c.Comment
    If cmt Is Nothing Then
        c.AddComment
    End If
    c.Comment.Text Text:=CStr(c.Value)
    c.Value = 1
Next
End Sub

Open in new window

Regards

EDIT test if already a comment
0
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 1000 total points
ID: 40539903
Sub Convert()
Dim strString As String
For Each myCell In Selection
    If myCell.Value <> "" Then
    myCell.AddComment
    myCell.Comment.Visible = False
    strString = myCell.Value
    myCell.Comment.Text Text:=strString
    myCell.Value = "1"
    End If
Next
End Sub

Open in new window

0
 
LVL 6

Author Closing Comment

by:Flora
ID: 40539907
both codes were excelent

thank you both.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question