Thread: Changing cell contents to various other values
Started 1 month, 1 week ago by wilmapayne
I'm working on a database query (I'm a RANK beginner!). I've managed to get the data into my spreadsheet. But I need to change values, depending on the value in the cell. Here's what it looks like:
If the value from my database is 0, I need to get 006 into my spreadsheet.
If the value from the db is 1 through 9, I need to multiply by 10 and show 10, 20, etc. in my spreadsheet - ...
Hi
paste the following codes in the macro window ( alt F11) and run the macro.
Code:
Sub wilma()
Cells.NumberFormat = "@"
For Each cell In ActiveSheet.UsedRange
If cell.Value = 0 Then
cell.Value = "006"
ElseIf cell.Value > 0 And cell.Value < 10 Then
cell.Value = "0" & cell.Value * 10
ElseIf cell.Value > 9 Then...
Re: Changing cell contents to various other values
Hi
paste the following codes in the macro window ( alt F11) and run the macro.
Code:
Sub wilma()
Cells.NumberFormat = "@"
For Each cell In ActiveSheet.UsedRange
If cell.Value = 0 Then
cell.Value = "006"
ElseIf cell.Value > 0 And cell....
Re: Changing cell contents to various other values
Thank you, Ravi. I created the macro (first time I've ever done one of those, so it took me awhile!!). When I run it, I get a message that says "Run-time error '13': Type mismatch. When I click Debug, the code comes up with the last line before End If highlighted in yellow: cell...
Re: Changing cell contents to various other values
HI
try these codes. It applies only to col D.
Code:
Sub wilma()
Dim a As Long, x As Long
x = Cells(Rows.Count, 1).End(xlUp).Row
Range("D1:D" & x).NumberFormat = "@"
For a = 2 To x
If Cells(a, 4) = 0 Then
Cells(a, 4) = "006"
ElseIf Cells(a, 4) > ...
HI
try these codes. It applies only to col D.
Code:
Sub wilma()
Dim a As Long, x As Long
x = Cells(Rows.Count, 1).End(xlUp).Row
Range("D1:D" & x).NumberFormat = "@"
For a = 2 To x
If Cells(a, 4) = 0 Then
Cells(a, 4) = "006"
ElseIf Cells(a, 4) > 0 And Cells(a, 4) < 10 Then
Cells(a, 4) = "0" & Cells(a, 4) = Cells(a, 4) * 10
ElseIf ...
Hi - I'm sorry to keep bothering...this code works perfectly on the correct column, and returns the x10 result on all values greater than 9, but the first two options return a value of FALSE when I run the macro. Any suggestions?
Re: Changing cell contents to various other values
Hi - I'm sorry to keep bothering...this code works perfectly on the correct column, and returns the x10 result on all values greater than 9, but the first two options return a value of FALSE when I run the macro. Any suggestions?
Re: Changing cell contents to various other values
Hi
replace the line Cells(a, 4) = "0" & Cells(a, 4) = Cells(a, 4) * 10 with Cells(a, 4) = "0" & Cells(a, 4) * 10
Ravi
Re: Changing cell contents to various other values Hi replace the line Cells(a, 4) = "0" & Cells(a, 4) = Cells(a, 4) * 10 with Cells(a, 4) = "0" & Cells(a, 4) * 10 Ravi
SO PRETTY:... SO PRETTY: =IF(ISERR(FIND("?",CELL("contents",$E2))),IF(ISERR(FIND("X",CELL("contents",$B2))),TRUE,FALSE),FALSE)
1:12 PM Nov 19th
from Echofon
FUCKING NDA question: How can I make my table cell... FUCKING NDA question: How can I make my table cell respond to an edit call by changing its contents? (beyond just indent)
01:59 AM August 08, 2008
from twitterrific
Thread profile page for "Changing cell contents to various other values" on http://www.mrexcel.com.
This report page is a snippet summary view from a single thread "Changing cell contents to various other values", located on the Message Board at http://www.mrexcel.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity