ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stupid question - Put a value in a cell? (https://www.excelbanter.com/excel-programming/301031-stupid-question-put-value-cell.html)

43fan

Stupid question - Put a value in a cell?
 
I'm running a routine that searches through an array to find a value. If it
finds it, it creates another routine that pastes certain values into another
sheet.

All I want to do is, if it finds those values, I want to put an "X" into
certain cells on another sheet. See, I said it was a stupid question. ;)
But, as a novice, it really has me stumped.

Thanks!
Shawn



Frank Kabel

Stupid question - Put a value in a cell?
 
Hi
best way: post your existing code so one can adapt/change this :-)


--
Regards
Frank Kabel
Frankfurt, Germany


43fan wrote:
I'm running a routine that searches through an array to find a value.
If it finds it, it creates another routine that pastes certain values
into another sheet.

All I want to do is, if it finds those values, I want to put an "X"
into certain cells on another sheet. See, I said it was a stupid
question. ;) But, as a novice, it really has me stumped.

Thanks!
Shawn



43fan

Stupid question - Put a value in a cell?
 
Frank,

I can do that, no prob., in fact it'll be posted below. But, basically, how
to you just insert a value in a field?

Here's the code:(initially gotten from here, then modified) :)

Set Myrange = Intersect(ActiveSheet.UsedRange, Columns("B"))
If Myrange Is Nothing Then Exit Sub
Application.ScreenUpdating = False
FindRange = Array("MLAP")
For Each elem In FindRange
Set C = Myrange.Find(elem, Myrange.Cells(1), xlValues, xlPart)
If C Is Nothing Then Exit Sub
VehicleCell = "$A$" & Trim(Str(C.Row))
If Not C Is Nothing Then
If CopyRange Is Nothing Then Set CopyRange = Range(VehicleCell)
firstaddress = C.Address
Do
Set C = Myrange.FindNext(C)
VehicleCell = "$A$" & Trim(Str(C.Row))
Set CopyRange = Union(CopyRange, Range(VehicleCell))
Loop While firstaddress < C.Address
End If
Next
Application.ScreenUpdating = True
If CopyRange Is Nothing Then Exit Sub
CopyRange.Copy

Sheets("Monday - Garage").Select
Range("A12").Select
ActiveSheet.Paste
Range("A26").Select
ActiveSheet.Paste

--------
This part all works fine and does what I want to do. Now that it's "found"
the values, I want to put an X in cells D12.... actually, just had another
thought. Since the values may be found in multiple cells throughout, I need
to put X's in multiple rows as well. There may be say 5 instances,
CopyRange has all five vehicle numbers in it, and gets pasted where it needs
to be. I guess what I need to do is somehow make CopyRange equal to the
vehicle number, plus the X's it needs? Can CopyRange be Vehicle number +
two empty cells, plus X, empty cell, then X, etc, etc.?

Not sure if I've explained this well or not, but I'm heading back to try
making CopyRange equal to everything I need. :)

Cells(D, 12) = "X"

"Frank Kabel" wrote in message
...
Hi
best way: post your existing code so one can adapt/change this :-)


--
Regards
Frank Kabel
Frankfurt, Germany


43fan wrote:
I'm running a routine that searches through an array to find a value.
If it finds it, it creates another routine that pastes certain values
into another sheet.

All I want to do is, if it finds those values, I want to put an "X"
into certain cells on another sheet. See, I said it was a stupid
question. ;) But, as a novice, it really has me stumped.

Thanks!
Shawn





Frank Kabel

Stupid question - Put a value in a cell?
 
Hi
to insert a value use something like
with range("B1")
.value="your_value"
end with

--
Regards
Frank Kabel
Frankfurt, Germany


43fan wrote:
Frank,

I can do that, no prob., in fact it'll be posted below. But,
basically, how to you just insert a value in a field?

Here's the code:(initially gotten from here, then modified) :)

Set Myrange = Intersect(ActiveSheet.UsedRange, Columns("B"))
If Myrange Is Nothing Then Exit Sub
Application.ScreenUpdating = False
FindRange = Array("MLAP")
For Each elem In FindRange
Set C = Myrange.Find(elem, Myrange.Cells(1), xlValues, xlPart)
If C Is Nothing Then Exit Sub
VehicleCell = "$A$" & Trim(Str(C.Row))
If Not C Is Nothing Then
If CopyRange Is Nothing Then Set CopyRange = Range(VehicleCell)
firstaddress = C.Address
Do
Set C = Myrange.FindNext(C)
VehicleCell = "$A$" & Trim(Str(C.Row))
Set CopyRange = Union(CopyRange, Range(VehicleCell))
Loop While firstaddress < C.Address
End If
Next
Application.ScreenUpdating = True
If CopyRange Is Nothing Then Exit Sub
CopyRange.Copy

Sheets("Monday - Garage").Select
Range("A12").Select
ActiveSheet.Paste
Range("A26").Select
ActiveSheet.Paste

--------
This part all works fine and does what I want to do. Now that it's
"found" the values, I want to put an X in cells D12.... actually,
just had another thought. Since the values may be found in multiple
cells throughout, I need to put X's in multiple rows as well. There
may be say 5 instances, CopyRange has all five vehicle numbers in it,
and gets pasted where it needs to be. I guess what I need to do is
somehow make CopyRange equal to the vehicle number, plus the X's it
needs? Can CopyRange be Vehicle number + two empty cells, plus X,
empty cell, then X, etc, etc.?

Not sure if I've explained this well or not, but I'm heading back to
try making CopyRange equal to everything I need. :)

Cells(D, 12) = "X"

"Frank Kabel" wrote in message
...
Hi
best way: post your existing code so one can adapt/change this :-)


--
Regards
Frank Kabel
Frankfurt, Germany


43fan wrote:
I'm running a routine that searches through an array to find a
value. If it finds it, it creates another routine that pastes
certain values into another sheet.

All I want to do is, if it finds those values, I want to put an "X"
into certain cells on another sheet. See, I said it was a stupid
question. ;) But, as a novice, it really has me stumped.

Thanks!
Shawn




All times are GMT +1. The time now is 10:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com